LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Unable to redirect script output to a file (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-redirect-script-output-to-a-file-750047/)

alien12 08-25-2009 02:48 AM

Unable to redirect script output to a file
 
Hi,
I have a python script that when run outputs to screen.

eg.
./international_sms_check.py 0403000511 919227434827
TS 21 check ok
TS 22 check ok
sms successfully delivered from 61403000511 to 919227434827


But when I try:
./international_sms_check.py 0403000511 919227434827 > test

The file test is created but there is nothing in it.

if I try ls > test this works fine with output of ls redirected to file test.

Can anyone help :(

colucix 08-25-2009 02:51 AM

Maybe it writes to standard error instead of standard output. You can verify using:
Code:

./international_sms_check.py 0403000511 919227434827 > test 2>&1
to redirect both to the test file.

alien12 08-25-2009 03:16 AM

Unable to redirect script output to a file
 
I tried ./international_sms_check.py 0403000511 919227434827 > test 2>&1

But nothing in test2 file :(

colucix 08-25-2009 03:20 AM

What python statements did you use to print out the messages? The solution can be in the python code itself, but it's hard to tell without knowing how it is implemented.

alien12 08-25-2009 03:36 AM

YES, thank you :) checked code, and was exiting with 1 instead of zero.


All times are GMT -5. The time now is 07:24 AM.