LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-23-2001, 09:43 AM   #1
bfloeagle
Member
 
Registered: Jun 2000
Location: Upstate New York
Distribution: Ubuntu
Posts: 158

Rep: Reputation: 30
Arrow @echo off -> Exist in Linux?


I am writing some programs (not really programs - just executable text files with multiple command prompt commands) to make running my system a little easier. I have added them to cron and they are running perfectly.

The only problem I have with them is that they output info. One uses the 'service' program that comes with RH and outputs the result of turning on/off a service. When these are run by cron, it sends an email to root displaying the output. Not that I mind seeing that my programs are working, but now I have a couple hundred messages in my inbox giving my the output for every program after it has run.

Back in the DOS days, you could put '@echo off' into batch files (like the autoexec.bat) to hide all the output of the commands. Is there a way to do this in Linux?

Andy
 
Old 07-23-2001, 10:45 AM   #2
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
You can just redirect the output of STDOUT and STDERR to /dev/null by using
Code:
program >/dev/null 2>&1
The above example assumes that you are using bash/sh.

HTH

Jamie...
 
Old 07-23-2001, 10:05 PM   #3
bfloeagle
Member
 
Registered: Jun 2000
Location: Upstate New York
Distribution: Ubuntu
Posts: 158

Original Poster
Rep: Reputation: 30
Unhappy Just want to be sure...

Just to play stupid, and to make sure I understood you right, I would put that entire line (with 'program' being the name of the file) into my cron job?

What does the '2>&1' mean?

Andy
 
Old 07-24-2001, 01:19 PM   #4
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
Code:
program >/dev/null 2>&1
is the same as writing
Code:
program >/dev/null 2>/dev/null
the > is the redirect for STDOUT (standard out), the 2> is the redirect for STDERR (standard error)

cheers

Jamie...
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux echo effect Youssef_C Linux - Software 1 10-31-2004 04:26 PM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 02:59 PM
Need Linux Help:Problem with disabling echo ebh1 Programming 1 09-22-2003 04:04 PM
Echo /devPrinting doesn't work, echo /usb/lp0 works, Testpage works, Printing doesn't Hegemon Linux - General 3 08-15-2002 01:13 PM
Using echo with ksh on Linux... King V Programming 0 11-07-2001 09:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:34 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
Open Source Consulting | Domain Registration