How to redirect stdout & stderr to a logfile
Hello All,
I'm new to java. I have to redirect all the output that get printed to a logfile (text) on my hard disk?
Can anyone plz give me a pointer?
thanks
Sumanth
He probably means this but doesnt know how to ask for it:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html
static void setErr(PrintStream err)
Reassigns the "standard" error output stream.
static void setIn(InputStream in)
Reassigns the "standard" input stream.
static void setOut(PrintStream out)
Reassigns the "standard" output stream.
Similar Messages
-
Feature Request: stdin/stdout/stderr redirection
I know that CLibInit.setSprite() can setup a text area for
this purpose - I haven't gotten this to work at all since I've been
using gluegen wrappers and you need to call setSprite() before
init() and the glugen wrappers do init() when the static class is
loaded. Being able to call setSprite() at any time would be a boon.
But even if I get setSprite() to work, I'd like to be able to
redirect stdin/stdout/stderr to use some buffers that I can control
the use of.
Need to play with file access but something similar would be
nice there too - controlling file handles to go to buffers under my
control.Lexion wrote:[...]
int redirect_io()
freopen(in, "r", stdin);
return 0;
int shell_write(char *s)
// write command to stdin file
fprintf(stdin, "%s\n", s);
return 0;
I don't think its related, but you are writting to a file opened for reading. I believe bash is exiting because after reading the ls command there's nothing left in the file and it gets an EOF.
You should be using pipes here:
int fork_shell()
/* call pipe(), it will give you two file descriptors,
* one for each end of the pipe.
// fork another thread to run shell
shell_pid = fork();
if (shell_pid == 0)
/* close the write end */
/* reassing stdin to the read end, using dup() i think */
/* reopen stdout to a file (or the write end of another pipe
* if you want the output to go back to the parent process)
char *cmd[] = {"/bin/bash", NULL};
execv(cmd[0], cmd);
_exit(0);
/* you may reassing stdout to the write end of the pipe or use it
* explicitly when sending commands to bash
return 0;
Last edited by diegonc (2010-07-28 14:24:02) -
I am using following code to execute process and capture stderr/stdout:
proc = window.cep.process.createProcess('/path/to/nodejs','/path/to/script.js');
// proc.data is a PID
window.cep.process.stdout(proc.data,function(line){
console.log(line);
window.cep.process.stderr(proc.data,function(line){
console.log(line);
And here is my script.js:
console.log('abcdef');
console.log('12345');
console.log('gghhtt');
For some reason only the first line ('abcdef') is printed by stdout handler (handler is called only once)... Next lines are ignored and callback is never called again. What I am doing wrong?
Adobe Photoshop Version: 14.2 (14.2 20131211.r.515 2013/12/11:23:00:00) x64
Operating System: Mac OS 10.9.1There is nothing wrong in your code. This is a limitation of cep.process.stdout/stderr which is targeting to capture one time of stdout/stderr output. For now, two workarounds are suggested as the following.
a. Embed cep.process.stdout/stderr, like the code below
window.cep.process.stdout(proc.data,function(line){
console.log(line);
window.cep.process.stdout(proc.data,function(line2){
console.log(line2);
window.cep.process.stdout(proc.data,function(line3){
console.log(line3);
b. Join all stdout output as one, like
var str1 = 'abcdef';
var str2 = '12345';
var str3 = 'gghhtt';
console.log(str1 + str2 + str3);
Besides, the good news is since CEP5, nodejs is integrated into CEP and your script could be executed in Html engine of CEP directly. My guess is Photoshop 15.0 will probably pick up CEP5 to involve the benefit in. Kindly let me know if you need more information. -
Calling Unix-Script from within Oracle and store stdout/stderr in table
Hi,
What I want to do is:
1. Calling a UNIX script (e.g. hello.sh) (from inside the Database)
hello.sh
echo Hello World!
2. and get the stdout/stderr output back in my Database in a table (e.g. temp_back)
table temp_back
ID stdout stderr
1 Hello World!
I think Number 1 isnt a big problem, but how to get stdout back in DB?
Any solution?
I searched a bit in this Forum and found this Post.
re:Calling Host Command Through Database Procedures or Triggers
This may be what I am searching for, but cant access the Link
Since I am not really fit with UNIX and packages/procedures in Oracle it would be nice if you could post a very detailed answer.
(Please no java)
-What packages do I need? (heard DBMS_OUTPUT would be useful)
-example PL/SQL script
Thanks a lot!
Marcus
Environment:
Oracle 9.2.0 DBMarcus, if you opened the Java sandbox to access any o/s file, you can call any Unix command, shell script, or program, that the Oracle o/s user has exec privs on.
Just remember that there's a very basic Unix environment when you make the call - the settings in the .profile does not apply. Thus PATH for example is not set. When making the call make sure that the complete path is given. As for the environment, that is a problem as you cannot set that and make the call at the same time.
In that case it is much simpler to rather write a Unix shell script that does all for you. Set the environment. Run the command(s). Format output. Etc.
Then you call that Unix script, via Java, from SQL or PL/SQL. Treat the Unix scripts like the Unix-version of stored procedures for your Oracle application.
Some technical details. When you connect to Oracle, a Unix process services you. This can be either a dedicated server process (servicing only your Oracle session) or a shared server process (from the shared service pool of processes).
In either case, it is a Unix process running as a background process (thus detached from any tty device). PL/SQL and SQL are executed by this process. The Oracle JVM created by your session also lives in this process. When you therefore make o/s calls, these calls are made by this process.
Therefore you are limited to what this process can and can't do. E.g. it runs as the oracle o/s user and will fail on accessing paths and commands does the oracle user does not have privs on. Etc. -
Redirecting stdout in 64 bit mode
Hi,
I have a problem. I wanted to redirect stdout to a text file and back. In 32 bit mode everything works fine using file member to struct FILE, but in 64 bit mode only data member FILE has long _pad[16]. Can anyone tell me how to use this to redirect stdout to file and visevesra. Thanks in advance.
AmandeepBy default in 10.6.8 it should be in 64 bit mode but to check and change it in Finder highlight Aperture, the application, and go command I to open the info window and look about 1/4 of the way down
(Note this is from Lion so it is slightly different then what you will see) -
Call executable and stdout/stderr
Is there a possibility to save the output of commandline program which writes to stdout/stderr and which is run from a call executable teststep other than to redirect the stdout/stderr channels to a file ?
The Call Executable Step Type does is not able to access the stdout/stdin/stderr at the present time. This may be a feature we consider adding for a future version of TestStand.
One workaround you can do is to call an executable from another environment (such as LabVIEW), and create a custom step type from this.
Allen P.
NI -
StdIn, stdOut, stdErr for Runtime.exec()
I have searched through 100s of forum messages regarding this topic, but none have helped me enough.
I have an application, app_A, that allows the user to select a database and other environment settings and then run an application using the selected settings. Running app_A on Windows 2000 using a Shortcut with the command: java.exe app_A automatically opens a dos window to write stdOut and stdErr (this is good). From within app_A I do the following:
Runtime rt = Runtime.getRuntime();
rt.exec("java.exp app_B");
app_B, starts up just fine, except that I do not see the stdOut or stdErr from app_B.
Questions:
1. Where is it going and how can I get it?
2. Is there way app_B can have it's own stdOut & stdErr, so the dos window for app_A can be suppressed (it is not really needed)?
many thanks for help and direction
Brenthttp://www.apl.jhu.edu/~hall/CWP-Sources/CWP-Examples/Chapter8/Exec/Exec.html may be this class of Marty Hall can be usefull for you.
-
Primitivelogger - A barebones-simple file and/or stdout/stderr logger
Nothing too major to announce here, just thought I'd share in case anyone wanted to make use of this. Basically, I've been writing my media player app, and obviously found a need for logs. But for one, I wanted logs that could be colorized if they were headed to STDOUT/STDERR, and otherwise be "boring". And I just wanted something to code.
So, I present to you "primitivelogger", a reinventing-the-wheel-because-I-can barebones logger that uses Clint for color when sending things to the standard outs, which is the default. You can specify a log file and a date/time format when setting up the logger object, and use its 3 simple functions: info(), error(), and fatal(). Take a look on Github if you want. If you have an idea, fire away, I'm open to decent suggestions. And if you don't like it, well... that's cool too!
It's Python 2/3 compatable and is on the AUR as python[2]-primitivelogger-git. I dunno if I'll be making a non-git package or not. Might be useful for some cases but as I doubt this gets updated much, it'd probably be pretty redundant.what about
* * * * * /home/snuffy/myscript.sh > /tmp/snuffy.lis 2>&1
or
sqlplus -s /nolog >>$logfile 2>&1 <<EOF!
Edited by: user11181920 on Aug 13, 2012 5:10 PM -
[advanced] Runtime.exec() and ordering of stdout, stderr
Hi,
When invoking Runtime.exec(), I'd like to output the contents of stdout, stderr in the correct order. I am using Process.getInputStream(), Process.getErrorStream() and output those but I can't get the order right.
For example, the following events occur:
1) stdout: "c:\> dirt"
2) stderr: "dirt is a bad command or filename"
3) stdout: "c:\>"
When I run my program I get the following output:
c:\> dirt
c:\>
dirt is a bad command or filename
My output has #1 and #3 merged and #2 in its own. The placement of stderr is crucial in my program; how can I possibly synchronize the two streams and know which text goes where?
Please help.
GiliCrosspost. See Advanced forum.
-
How to redirect to different page after login in APEX 4.1
Dear All,
Here my Requirement is,When the users login,
when they entered their username and password and pressed login button,
they have to redirected to different pages based on the type of user.
Here my LOGIN_TABLE has following 3 columns,
1.Username
2.Password
3.Type.
The TYPE has 2 values, employee and admin.
when the type is admin they should be redirected to page 2,
reaining i.e employee users has to be redirected to page 3.
How can I do this? please give some suggestion.
Thank you.
regards,
GurujothiDear Christian,
Thank you for your reply,
I would like to explain something,
When I using the following function,
*create or replace FUNCTION custom_auth_g (
p_username IN VARCHAR2,
p_password IN VARCHAR2)
RETURN BOOLEAN IS
BEGIN
FOR c1 IN (SELECT 1
FROM login_table
WHERE upper(username) = upper(p_username)
AND upper(password) = upper(p_password))
LOOP
RETURN TRUE;
END LOOP;
RETURN FALSE;
END;*
When login, It checks in the login_table table and if the username is exist with the pass word it successfully entered inside the application.
for all users only one page which we set.
My Login_table also contains type which has 2 type as I mentined above.
But As I mentioned earliar based on the user type it has to be redirected to 2 different page.
I found this Package but I cant understand,Can you please Explain?
*create or replace PACKAGE app_security_pkg
AS
PROCEDURE add_user
p_username IN VARCHAR2
,p_password IN VARCHAR2
PROCEDURE login
p_uname IN VARCHAR2
,p_password IN VARCHAR2
,p_session_id IN VARCHAR2
,p_flow_page IN VARCHAR2
FUNCTION get_hash
p_username IN VARCHAR2
,p_password IN VARCHAR2
RETURN VARCHAR2;
PROCEDURE valid_user2
p_username IN VARCHAR2
,p_password IN VARCHAR2
FUNCTION valid_user
p_username IN VARCHAR2
,p_password IN VARCHAR2
RETURN BOOLEAN;
END app_security_pkg;*
*create or replace PACKAGE BODY app_security_pkg
AS
PROCEDURE login
p_uname IN VARCHAR2
,p_password IN VARCHAR2
,p_session_id IN VARCHAR2
,p_flow_page IN VARCHAR2
IS
lv_goto_page NUMBER DEFAULT 1;
BEGIN
-- This logic is a demonstration of how to redirect
-- to different pages depending on who successfully
-- authenticates. In my example, it simply demonstrates
-- the ADMIN user going to page 1 and all other users going
-- to page 2. Add you own logic here to detrmin which page
-- a user should be directed to post authentication.
IF UPPER(p_uname) = 'ADMIN'
THEN
lv_goto_page := 1;
ELSE
lv_goto_page := 2;
END IF;
APEX_UTIL.SET_SESSION_STATE('FSP_AFTER_LOGIN_URL');
wwv_flow_custom_auth_std.login
p_uname => p_uname,
p_password => p_password,
p_session_id => p_session_id,
p_flow_page => p_flow_page || ':' || lv_goto_page
EXCEPTION
WHEN OTHERS
THEN
RAISE;
END login;
PROCEDURE add_user
p_username IN VARCHAR2
,p_password IN VARCHAR2
AS
BEGIN
INSERT INTO app_users (username, PASSWORD)
VALUES (UPPER (p_username),
get_hash (TRIM (p_username), p_password));
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
ROLLBACK;
RAISE;
END add_user;
-- Function to Perform a oneway hash of the users
-- passwords. This cannot be reversed. This exmaple
-- is a very week hash and if been used on a production
-- system, you may want to use a stronger hash algorithm.
-- Read the Documentation for more info on DBMS_CRYPTO as
-- this is the supported package from Oracle and
-- DBMS_OBFUSCATION_TOOLKIT is now depricated.
FUNCTION get_hash (p_username IN VARCHAR2, p_password IN VARCHAR2)
RETURN VARCHAR2
AS
BEGIN
RETURN DBMS_OBFUSCATION_TOOLKIT.md5 (
input_string => UPPER (p_username)
|| '/'
|| UPPER (p_password));
END get_hash;
PROCEDURE valid_user2 (p_username IN VARCHAR2, p_password IN VARCHAR2)
AS
v_dummy VARCHAR2 (1);
BEGIN
SELECT '1'
INTO v_dummy
FROM app_users
WHERE UPPER (username) = UPPER (p_username)
AND PASSWORD = get_hash (p_username, p_password);
EXCEPTION
WHEN NO_DATA_FOUND
THEN raise_application_error (-20000, 'Invalid username / password.');
END valid_user2;
FUNCTION valid_user (p_username IN VARCHAR2, p_password IN VARCHAR2)
RETURN BOOLEAN
AS
BEGIN
valid_user2 (UPPER (p_username), p_password);
RETURN TRUE;
EXCEPTION
WHEN OTHERS
THEN RETURN FALSE;
END valid_user;
END app_security_pkg;*
And you said "assign an URL to FSP_AFTER_LOGIN_URL, depending on the Type column",
Where to assign,Could you please Explain?
Thank you. -
How to display swf in full screen mode and how to redirect to a url
Hi,
I have 2 questions :
Question 1 - I have a flash swf file and I want to display it in the browser in full mode meaning it should fit the browser, I have tried adding
fscommand("fullscreen", "true");
in the first frame of a lyaer but it does not work.
Question 2 - How to redirect to another page at the end of the swf movie, I have tried adding :
stop();
navigateToURL( new URLRequest("*www.microsoft.com*"), "_self");
in the last frame but it does not work.
Thank you very very much for your assitance !!
Terry"fscommand("fullscreen", "true");" only works for self-running executables, not embedded SWFs in a web page.
To get the swf to fill the browser page, the best thing to do would be to adjust the publish settings of the "HTML Wrapper" page and copy the necessary pieces from the resultant HTML file into the HTML file you are putting the swf into.
I have had some successes dealing with similar navigation issues by breaking up the code into multiple tasks:
var url:String = "http://www.microsoft.com";
var urlReq:URLRequest = new URLRequest(url);
navigateToURL(urlReq);
I can't guarantee that will help, but at least I tried. :-) -
How to redirect to other page in a dialogListener?
Hi All,
I am using JDeveloper 11g with ADF BC.
How to redirect to another page from a dialogListener of <af:dialog>?
I have a page with a [Delete] button on it. When user click on the delete button, a confirmation dialog will appear to ask "Are you sure? [Yes/No]". If user answer [Yes], I will delete the current record, and go to another page. I can call a Operation Binding in the dialogListener, but I don't know how to go to another page.
public void handleDeleteDialog(DialogEvent dialogEvent) {
OperationBinding operationBinding = bindings.getOperationBinding("Delete");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
// redirect to another page?
Regards,
Samson FuHi Samson,
Check following link for your query:-
Re: page has to navigate to the next page when clicking button in the popup
You can also make usae of Navigation Handler to invoke the navigation action in your task flow as
FacesContext facesCtx = FacesContext.getCurrentInstance();
NavigationHandler nh = facesCtx.getApplication().getNavigationHandler();
nh.handleNavigation(facesCtx, "", "ActionNameInTaskFlow");
Vikram -
How to redirect users to Custom Page on InfoView logoff
Post Author: Srinivas123
CA Forum: WebIntelligence Reporting
How to redirect the users on InfoView logoff to a custom page, instead of the default logon.aspx.Hello Senana,
Assuming you're using wwv_flow_custom_auth_std.login to log in, and p_flow_page is set to "[your app id]:1" try placing the following line just before your call to wwv_flow_custom_auth_std.login:
:FSP_AFTER_LOGIN_URL := null;This should force user to page 1 after log-in.
Hope this helps,
John -
How to redirect a JSP page after the session is killed
Hello!
I am quite new to JSP. I have a question about how to redirect a jsp page after the session is killed. Could anyone help?
thanks a lot in advance!You can't, directly. There's no connection betweenthe server and browser.
even after invalidating the session. we can do it
directly using the statement
response.sendRedirect("....");
or we can use the meta refresh tag.if session is invalidated and if we try to do response.sendRedirect(".. ") it throws IllegalStateException -
How to redirect a page to a new window instead of the current one
Can someone please tell me how to redirect a page to new window.
I mean I am running a JSP with a button and on clicking it i am opening a new window (thru javascript offcourse),
Now response.sendirect("New.jsp") should be opened in that new window opened.
I tried it but the New.jsp page is opened in the current page (Even though new window is opened ! ).
Please help.Hi,
U can use the following code to Pop up in new window
Jsp1.jsp
<%
if(action != "")
response .sendRedirect("Jsp2.jsp");
else
%>
<html><head><title>JSP 1</title>
<script language="JavaScript">
function View()
window.open("Jsp1.jsp?action=view","View","");
</script>
</head><body>
<form name="frm" method="post">
<input type="button" value="View" onclick="View()">
</form>
</body>
</html>
<%
Maybe you are looking for
-
HT1692 how do we move contacts from window mail to ipad?
We need tp figure out how to move our ccntacts from the computer on windows mail onto the ipad
-
Delete a database from a server in Business Process Architect
Hi Friends, Does anybody know how to delete a database from a server in Business Process Architect? I don't see any option to perform delete. I am using version 10.1.3.4. Thanks Tridib
-
Alignment of the components inside tab in JTabbedPane
I want to align the components inside the tab in tabbedpane. I have three tabs in the tabbed pane For each tab I added the components on the panel and added the panel as a tab. But as the number of components on each tab are not same the components i
-
I'm unable to reinstall Mountain Lion OS X on my Macbook. What should I do?
I was given a MacBook Pro from a friend, but it was still left with everything on it. I started to restore it to factory settings so it would be wiped clean and I could use it as a new computer. Once I was about to reinstall Mountain Lion OS X, it no
-
Hi, When we deploy a HTTPServlet to OAS, we can deploy it only as JServlet and after registering the servlet, if we look into the wrb.app, it says that the Execution string is wrks -s. Because of this, when my applet communicates with the servlet and