LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 01-30-2015, 03:54 AM   #1
karkotagan
LQ Newbie
 
Registered: Jan 2015
Posts: 3

Rep: Reputation: Disabled
How do I pass the command line errors to a file.


I am writing a pythong program which has command line executions for linux like ls and restart. I want to know how to pass the errors from the command executed to a file so that it becomes a log.
 
Old 01-30-2015, 04:21 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,261

Rep: Reputation: 297Reputation: 297Reputation: 297
A command can print two kinds of output: Normal output and error output.

If you want two different files:

command >/tmp/normal-output.txt 2>/tmp/error-messages.txt

Or if you want both in one file:

command >/tmp/output.txt 2>&1
 
Old 01-30-2015, 06:25 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
you can find some tips here: http://www.linuxquestions.org/questi...ommand-624303/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
pass parameter into a program via the make command line knobby67 Programming 5 01-24-2014 03:55 AM
pass parameter in command line lingyun Linux - Newbie 4 04-21-2009 11:42 PM
[SOLVED] pass file-name as command line argument vikas027 Programming 2 10-15-2008 12:52 AM
Cant pass command line args in flwm.desktop deep_inda_jungl Ubuntu 1 05-02-2008 04:05 PM
Pass command line instructions during install? Clayton8 Linux - Newbie 7 11-07-2007 04:15 AM


All times are GMT -5. The time now is 06:40 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration