execute a command silently or quietly within a shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting execute a command silently or quietly within a shell
# 1  
Old 12-15-2007
execute a command silently or quietly within a shell

How do I suspend output of commands and tools that sometimes utter unwanted output? I know that I can always pipe to null or some such thing, but is there a simpler more elegant (i.e. accepted) practice?
# 2  
Old 12-15-2007
Some commands and tools have options for silent mode. However the accepted practice is to send stderr to /dev/null.
# 3  
Old 12-15-2007
I really have to learn to phrase more carefully. I didn't mean to imply error output, but really just the FYI kind of messages that might complement the actual work or output of a tool. Something like "...done. 5 instances found", where the work was desired, but the chit chat wasn't.

If I remember correctly, in DOS this was accomplished by preceding the statement with an apostrophe. Now it's done by "echo off".

Thanks for the reply, btw.
# 4  
Old 12-15-2007
Some commands have quiet/verbose mode, check what commands are being used. The tradition is that tools are quiet unless told to be verbose.

What command is it that is outputing the unwanted blurb?
# 5  
Old 12-15-2007
A process normally has two outputs to screen: stdout (standard out), and stderr (standard error).

Normally informational messages go to sdout, and errors and alerts go to stderr.

You can turn off stdout for a command by doing

Code:
mycommand >/dev/null

and turn off stderr by doing:

Code:
mycommand 2>/dev/null

If you want both off, you can do:

Code:
mycommand 2>&1 >/dev/null

(The 2>&1 says send stderr to the same place as stdout.)

Turning around the notes about the "-v" for verbose convention; some commands have a "-q" (quiet) option, eg. "grep -q".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to execute application command in shell script?

friends, i have application commands to execute in shell script it is something like this. i will login with user data it takes me to $ prompt. Example given below login: data ps : xxxx $ MNSinput --this takes me to greater than prompt > > ops --this is command i enter this output... (7 Replies)
Discussion started by: udaykrishna
7 Replies

2. Shell Programming and Scripting

Need to execute Oracle relocation command in shell script

Hello, I need to execute below command in shell script srvctl relocate service -d $database -s $service -i $avail -t $pref -f and also need to get the errors ,if any,in another file. What's the right way to execute such commands in shell script? Best regards, Vishal (1 Reply)
Discussion started by: Vishal_dba
1 Replies

3. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

4. UNIX for Dummies Questions & Answers

How to execute command after telneting in shell script?

Hi , I have to write a shell script to telnet to specific host and execute the admin command there. Please help me to do that. Eg : telnet hostname portno admin command exit (3 Replies)
Discussion started by: arukuku
3 Replies

5. Shell Programming and Scripting

Execute a shell script after a particular command is run

Hi, I need to run a script whenever the Cron file is modified. The requirement is whenever a user modifies the cron file, the script should run automatically. Can you please provide your inputs ? (5 Replies)
Discussion started by: harneet2004us
5 Replies

6. Shell Programming and Scripting

write a shell script to execute a command

Hello all, I have just started doing shell scripting. I want to read a file which stores the status of my job I have submitted on a cluster. The file looks something like this : ========================FILE============================= crab: Checking the status of all jobs: please wait... (4 Replies)
Discussion started by: learn_linux
4 Replies

7. Shell Programming and Scripting

Cann ot execute a shell command

Hi , I am new to UNIX and Shell scripting . I am not able to execute a shell file . I try to do it using the below command. ./start.sh but it shows an error that 'cannot execute ' what might be the reason for this? pls help me to resolve it. (1 Reply)
Discussion started by: Deepakkumard
1 Replies

8. Shell Programming and Scripting

the shell not pause when execute read command

Hi, i facing a problem when run the script below.. while do if then printf "Please enter a name : " read response # the problem occur here if then ea_ident=${omc_ident} else # # Check that name does not contain invalid... (14 Replies)
Discussion started by: neruppu
14 Replies

9. Shell Programming and Scripting

shell script to execute user command

I don't know why the following shell script doesn't work. Could you please help me out? #!/usr/bin/ksh test="cal > /tmp/tmp.txt 2>&1" $test I know it will work for the following format: #!/usr/bin/ksh cal > /tmp/tmp.txt 2>&1 However, I need to get the command from the user in... (1 Reply)
Discussion started by: redtiger
1 Replies

10. Shell Programming and Scripting

execute shell command in perlscript

Hi I have this below script...I want to execute the shell command "rm" in the below script but it is not working. Can anybody why so? I got the below error rm: /users/amvarma is a directory sh: /*-log*: not found ------------------- $u=`whoami`; print "$u\n"; $op_1=$ARGV; # for... (0 Replies)
Discussion started by: amitrajvarma
0 Replies
Login or Register to Ask a Question