LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-25-2009, 02:48 AM   #1
alien12
LQ Newbie
 
Registered: Aug 2009
Posts: 3

Rep: Reputation: 0
Unhappy 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
 
Old 08-25-2009, 02:51 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
Old 08-25-2009, 03:16 AM   #3
alien12
LQ Newbie
 
Registered: Aug 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Unable to redirect script output to a file

I tried ./international_sms_check.py 0403000511 919227434827 > test 2>&1

But nothing in test2 file
 
Old 08-25-2009, 03:20 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
Old 08-25-2009, 03:36 AM   #5
alien12
LQ Newbie
 
Registered: Aug 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Lightbulb

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Scripting: Redirect output of entire script to file & screen Kristijan Programming 3 10-12-2017 03:17 PM
cron job did not redirect output from bash script junust Programming 2 07-26-2009 04:30 AM
Shell scripting: How to redirect output from within the script itself? Arodef Linux - General 4 05-23-2006 07:30 PM
Redirect script output to log window in wxPython wapcaplet Programming 1 07-04-2004 08:59 PM
Can I redirect script output to a file without ">> $LOGFILE" at the end of each line davee Linux - General 1 12-19-2003 05:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration