Sponsored Content
Top Forums UNIX for Dummies Questions & Answers unix command - what happens under the hood Post 302348205 by awk on Thursday 27th of August 2009 04:09:25 PM
Old 08-27-2009
Quote:
Originally Posted by robert4732
Hello everyone,

When I run the command: rm adkjad (assuming the file adkjad doesn't exist), I get the following message:

adkjad: No such file or directory

I want to run this command, but I want a succesful return code whether the file is there or not.

I tried: rm adkjad 2> /dev/null , redirecting stderr to never never land, but I still get some type of negative return code.

Is there some other output(I am unware of) that I can send to /dev/null also?

Thanks in advance.

Robert
I like to use "rm -f" - the -f is force the remove, best used in batch jobs.

If the file is there or not, it will be removed and return a "0" status code.

However, if for some reason, you cannot delete the file (wrong ownership of the directory), it will return a bad code.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

wc command help.... and other unix command....... urgent

hi all. thanks for looking i am doing some homework. one question is that when type wc and then how to tell the program that we have finished entering data? also why do some operating systems report 22 as the number of bytes in the file above, while others only 20? thanks so much,... (1 Reply)
Discussion started by: dashi2k
1 Replies

2. Shell Programming and Scripting

How to use more than one MPE command STREAM with Unix command in a single shell?

Hello, I have problem in writing the shell script involving MPE command STREAM related to HP-UX and Unix command. Script is sh "nlshCMD 'STREAM <job name1>' | 'SHOWJOB' | grep $HPJOBNUM" sh "nlshCMD 'STREAM <job name2>' | 'SHOWJOB' | grep $HPJOBNUM" sh "nlshCMD 'STREAM <job name3>' |... (0 Replies)
Discussion started by: bosskr
0 Replies

3. HP-UX

How to use more than one MPE command STREAM with Unix command in a single shell?

Hello, I have problem in writing the shell script involving MPE command STREAM related to HP-UX and Unix command. Script is sh "nlshCMD 'STREAM <job name1>' | 'SHOWJOB' | grep $HPJOBNUM" sh "nlshCMD 'STREAM <job name2>' | 'SHOWJOB' | grep $HPJOBNUM" sh "nlshCMD 'STREAM <job name3>' |... (1 Reply)
Discussion started by: bosskr
1 Replies

4. Shell Programming and Scripting

assign a command line argument and a unix command to awk variables

Hi , I have a piece of code ...wherein I need to assign the following ... 1) A command line argument to a variable e.g origCount=ARGV 2) A unix command to a variable e.g result=`wc -l testFile.txt` in my awk shell script When I do this : print "origCount" origCount --> I get the... (0 Replies)
Discussion started by: sweta_doshi
0 Replies

5. UNIX for Advanced & Expert Users

unix command : how to insert text at the cursor location via command line?

Hi, Well my title isn't very clear I think. So to understand my goal: I have a script "test1" #!/bin/bash xvkbd -text blabla with xbindkeys, I bind F5 key in order it runs my test1 script So when I press F5, test1 runs. I'm under Emacs/Vi and I press F5 in order to have "blabla" be... (0 Replies)
Discussion started by: xib.be
0 Replies

6. UNIX for Dummies Questions & Answers

New to Unix command line and have a question about the "sort" command

I am going through the Unix Made Easy second edition book by John Muster. So far it's been very informative and I can tell it may be a bit out of date. In one of the exercises it talks about the "sort" command and using it to sort column's of data etc. The "sort" command has changed a bit and... (1 Reply)
Discussion started by: budfoxcat
1 Replies

7. UNIX Desktop Questions & Answers

Can Unix access Windows' File through Command Prompt in Unix

Hi all, I wish to know whether Unix can access window's file in Unix's terminal? Apart from that, how to copy files or share files between Window and Unix? I get to know of secure copy, however, my company's Unix does not support the feature of secure copy? Any other method for me to share/... (5 Replies)
Discussion started by: jessy83
5 Replies

8. Shell Programming and Scripting

Specify an entire UNIX command as a command line argument

I'm trying to write a bash script called YN that looks like the following YN "Specify a question" "doThis" "doThat" where "doThis" will be executed if the answer is "y", otherwise "doThat". For example YN "Do you want to list the file dog?" "ls -al dog" "" Here's my attempt... (3 Replies)
Discussion started by: LeoKSimon
3 Replies

9. Shell Programming and Scripting

UNIX command to copy files from Windows to UNIX box

Hi Folks, I have a file name abc.xml in my windows machine at the location c:\ytr\abc.xml which I want to place at the unix box machine inside cde directory.. at the following location that is /opt/app/cde/ now the credentials of unix box are abc345 -->(dummyid) ftyiu88--->(dummy passwd) ... (4 Replies)
Discussion started by: punpun66
4 Replies
runsv(8)                                                      System Manager's Manual                                                     runsv(8)

NAME
runsv - starts and monitors a service and optionally an appendant log service SYNOPSIS
runsv service DESCRIPTION
service must be a directory. runsv switches to the directory service and starts ./run. If ./run exits and ./finish exists, runsv starts ./finish. If ./finish doesn't exist or ./finish exits, runsv restarts ./run. If ./run or ./finish exit immediately, runsv waits a second before starting ./finish or restarting ./run. Two arguments are given to ./finish. The first one is ./run's exit code, or -1 if ./run didn't exit normally. The second one is the least significant byte of the exit status as determined by waitpid(2); for instance it is 0 if ./run exited normally, and the signal number if ./run was terminated by a signal. If runsv cannot start ./run for some reason, the exit code is 111 and the status is 0. If the file service/down exists, runsv does not start ./run immediately. The control interface (see below) can be used to start the ser- vice and to give other commands to runsv. If the directory service/log exists, runsv creates a pipe, redirects service/run's and service/finish's standard output to the pipe, switches to the directory service/log and starts ./run (and ./finish) exactly as described above for the service directory. The standard input of the log service is redirected to read from the pipe. runsv maintains status information in a binary format (compatible to the daemontools' supervise program) in service/supervise/status and service/log/supervise/status, and in a human-readable format in service/supervise/stat, service/log/supervise/stat, service/supervise/pid, service/log/supervise/pid. CONTROL
The named pipes service/supervise/control, and (optionally) service/log/supervise/control are provided to give commands to runsv. You can use sv(8) to control the service or just write one of the following characters to the named pipe: u Up. If the service is not running, start it. If the service stops, restart it. d Down. If the service is running, send it a TERM signal, and then a CONT signal. If ./run exits, start ./finish if it exists. After it stops, do not restart service. o Once. If the service is not running, start it. Do not restart it if it stops. p Pause. If the service is running, send it a STOP signal. c Continue. If the service is running, send it a CONT signal. h Hangup. If the service is running, send it a HUP signal. a Alarm. If the service is running, send it a ALRM signal. i Interrupt. If the service is running, send it a INT signal. q Quit. If the service is running, send it a QUIT signal. 1 User-defined 1. If the service is running, send it a USR1 signal. 2 User-defined 2. If the service is running, send it a USR2 signal. t Terminate. If the service is running, send it a TERM signal. k Kill. If the service is running, send it a KILL signal. x Exit. If the service is running, send it a TERM signal, and then a CONT signal. Do not restart the service. If the service is down, and no log service exists, runsv exits. If the service is down and a log service exists, runsv closes the standard input of the log service, and waits for it to terminate. If the log service is down, runsv exits. This command is ignored if it is given to service/log/supervise/control. Example: to send a TERM signal to the socklog-unix service, either do # sv term /etc/service/socklog-unix or # printf t >/etc/service/socklog-unix/supervise/control printf(1) usually blocks if no runsv process is running in the service directory. CUSTOMIZE CONTROL
For each control character c sent to the control pipe, runsv first checks if service/control/c exists and is executable. If so, it starts service/control/c and waits for it to terminate, before interpreting the command. If the program exits with return code 0, runsv refrains from sending the service the corresponding signal. The command o is always considered as command u. On command d first service/control/t is checked, and then service/control/d. On command x first service/control/t is checked, and then service/control/x. The control of the optional log service cannot be customized. SIGNALS
If runsv receives a TERM signal, it acts as if the character x was written to the control pipe. EXIT CODES
runsv exits 111 on an error on startup or if another runsv is running in service. runsv exits 0 if it was told to exit. SEE ALSO
sv(8), chpst(8), svlogd(8), runit(8), runit-init(8), runsvdir(8), runsvchdir(8), utmpset(8) http://smarden.org/runit/ AUTHOR
Gerrit Pape <pape@smarden.org> runsv(8)
All times are GMT -4. The time now is 07:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy