Sponsored Content
Top Forums Shell Programming and Scripting return code of a unix command Post 302129967 by ramky79 on Thursday 2nd of August 2007 03:15:07 PM
Old 08-02-2007
return code of a unix command

How to find out whether the command I executed is successful or unsuccessful(at commandlinet)

Eg:
say i execute the following command at command line
rm *
How do i find out whether my previous command is a success or failure.

Thankyou.

Best Regards,
Ram.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Move command return with exit code of 2

I have a script which loads data files into Oracle and then moves each file into a 'processed' directory when each file has finished loading. Last night I found that the script was failing on the mv statement (with a return code 2) and the following message, mv: cannot access... (1 Reply)
Discussion started by: handak9
1 Replies

2. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies

3. Shell Programming and Scripting

Return code of command assigned to variable

How do I evaluate the result of a command assigned to a variable?? Example: var1=`cmd` rc=$? rc will be the result of the assignment rather than cmd since it executes after. How do I evaluate the result of the command itself? Cheers..:confused: (2 Replies)
Discussion started by: browndr
2 Replies

4. HP-UX

return code from oracle to unix script

Hi I'm writing a shell script that connects to oracle database and fires query to check the availability of data in a table. In case of no data found then what will be the return code and how to handle in that in variable. Kindly provide with an example for better understanding... Thanks... (1 Reply)
Discussion started by: ksailesh
1 Replies

5. Shell Programming and Scripting

How to get the return code of subroutines executed as standalone as command line in Perl ?

How to do I get the return code of a subroutine in a perl module if invoke the subroutine as standalone, I have an module say TestExit.pm and in that i have a subroutine say myTest() which is returns 12, if i were to call the subroutine from command line like CASE:1 ( Without an explict... (2 Replies)
Discussion started by: ennstate
2 Replies

6. Shell Programming and Scripting

Writing a UNIX script from LOG to provide return code.

Folks - Firstly, I do apologize that my first post here is a question. I am quite familiar with UNIX since our application is running on it. We are trying to automate a few things on our end and I am challenged with a task in hand that requires UNIX scripting. I am totally a newbie in UNIX... (4 Replies)
Discussion started by: sk72
4 Replies

7. Shell Programming and Scripting

Managing awk return code over SSH command

Hello all, This bellow code works. I'm just trying to find a simplified way to achieve this. I'm sure there is an easier way and it must be to simple for me to find. Verify that the OS version is 6.1. If not exit the script. Of course if i just put a && exit 1 at the end of the ssh... (11 Replies)
Discussion started by: maverick72
11 Replies

8. Shell Programming and Scripting

Unix return code example

Hi, Does anyone here can guide me to understand how is return code works in a parent-child relation with a simple example? I have a request to build the script with return code in a child script, but i want to understand how does child script can return a code to the parent, stated if its... (4 Replies)
Discussion started by: khchong
4 Replies

9. Shell Programming and Scripting

save the return value of a unix command

Hi all, I am new in linux script, and I have the code below #!/bin/bash CMD="shuf -i 1-5 -n 1" $CMD echo $CMD exit 0 if I run the $CMD, it will return me a shuffle value. However, I need to save the return value of the shuffle, and use it later on. I tried for example print the... (3 Replies)
Discussion started by: peuceul
3 Replies

10. Shell Programming and Scripting

How to exit a shell script if a unix command does not return any value for 10 seconds?

Hi, Can anyone help me how to exit a shell script if a unix command inside does not return any value for 10 seconds? The scenarios is like this. I want to login to a application using shell script where the connection string is mentioned.but suppose this connection string is not... (10 Replies)
Discussion started by: arijitsaha
10 Replies
crontab(5)							File Formats Manual							crontab(5)

Name
       crontab - clock daemon table file

Syntax
       /usr/lib/crontab

Description
       The  command  executes  at  specified dates and times according to the instructions in the file. The file consists of lines with six fields
       each.  The format for a line is as follows:

	      minute hour day month weekday command

       The following list defines each field in the line:

       minute (0-59)  The exact minute that the command sequence executes.

       hour (0-23)    The hour of the day that the command sequence executes.

       day (1-31)     The day of the month that the command sequence executes.

       month (1-12)   The month of the year that the command sequence executes.

       weekday (1-7)  The day of the week that the command sequence executes. Monday = 1, Tuesday = 2, and so forth.

       command	      The complete command sequence variable that is to be executed.  Note that the command string must conform  to  Bourne  shell
		      syntax.

       The first five integer fields may be specified as follows:

       o   A single number in the specified range

       o   Two numbers separated by a minus, meaning a range inclusive

       o   A list of numbers separated by commas, meaning any of the numbers

       o   An asterisk meaning all legal values

       The sixth field is a string that is executed by the shell at the specified times.  A percent sign (%) in this field is translated to a new-
       line character.	Only the first line of the command field, up to a percent sign (%) or end of line, is executed by the  shell.	The  other
       lines are made available to the command as standard input.

Examples
       The following example is part of a file:
       # periodic things
       0,15,30,45 * * * * (echo '^M' `date`; echo '') >/dev/console
       0,15,30,45 * * * * /usr/lib/atrun

       # daily stuff
       5 4 * * * sh /usr/adm/newsyslog
       15 4 * * * ( cd /usr/preserve; find . -mtime +7 -a -exec rm -f {} ; )
       20 4 * * * find /usr/msgs -mtime +21 -a ! -perm 444 -a ! -name bounds
	    -a -exec rm -f {} ;

       # NOTE: The above line is wrapped.

       # local cleanups
       30 4 * * * find /usr/spool/mqueue -type f -mtime +5 -name df-exec rm {} ;
       35 4 * * * find /usr/spool/mqueue -type f -mtime +5 -name tf-exec rm {} ;
       40 4 * * * find /usr/spool/rwho -type f -mtime +21 -exec rm {} ;
       #

       # redirecting error output
       0 17 * * 1,3,5 /bin/tar -cv /usr/sysads/smith > /dev/console 2>&1
       #

Files
See Also
       sh(1), cron(8)
       Guide to System Environment Setup

																	crontab(5)
All times are GMT -4. The time now is 02:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy