Home > Return Code > Ksh Exit

Ksh Exit

Contents

The return code only gives you the return of the last command which was executed by the shell. But as i used a script that restarts the database, sqlplus has something done to hold the script.After many hours of debugging, if found out, that the file descriptor that redirect share|improve this answer edited Mar 24 at 3:08 mkobit 8,91154058 answered Nov 21 '11 at 20:07 havexz 7,96422126 You can see the $command is being used in the safeRunCommand's That helped. weblink

For this to work, replace cmd="$1"; $cmd with "[email protected]". You would have to do something like print out the return value with some tag you can grep out and sed the answer out. To "A reader" and Tom... share|improve this answer edited Oct 5 at 13:52 answered Jun 29 '12 at 3:53 Mark Reed 45k76098 yeah, I got it, Thanks! –user1317752 Jun 29 '12 at 4:49 try this

Ksh Exit

SP2-0734: unknown command beginning "SYSAUX ..." - rest of line ignored. Edit: Your script works only for one-word commands, like ls. Jean Afficher mon profil complet Reference TechChats IT-Bits Mon Wiki Archives du blog ► 2011 (2) ► septembre (1) ► mars (1) ► 2010 (10) ► octobre (1) ► septembre (2) What is this device attached to the seat-tube? 3% personal loan online.

Reply Link Erik February 15, 2016, 2:40 pm$ ssh localhost “./cyberciti; echo $?” Did you notice it was all in quotes? in1 ) echo "1 ;;2 ) echo "2" ;;0 ) echo "0";;esacsks A rigid mind is very sure, but often wrong. All rights reserved. Ksh If Condition The problem with echo is that it doesn't provide a way to deal with weird strings in variables: $ x=-n $ echo "$x" $ While both printf and print do: $

By using this site, you accept the Terms of Use and Rules of Participation. End of content United StatesHewlett Packard Enterprise International CorporateCorporateAccessibilityCareersContact UsCorporate ResponsibilityEventsHewlett Packard LabsInvestor RelationsLeadershipNewsroomSitemapPartnersPartnersFind a PartnerPartner Bash Get Return Code Of Last Command Perhaps an intro (or a web reference or book) into Ora to Unix communication/interaction might be of great value for those of us migrating from Windoze ;-) to Unix/Linux. That aside, you don't capture 'ERROR_CODE' so that is always zero (undefined). Instead, use printf - or if you don't mind being ksh-only, you can use print.

If you write a simple script like this: #!/bin/ksh ls -lai fdffds 2>/dev/null The return value from the script will be 1 (since this file does not exist). Bash If Exit Code Not 0 I am running Ubuntu Dapper Drake Linux.Keep it coming, it is good stuff.Rob Reply Link Rob April 3, 2007, 6:59 pmG'day again,Nope, I was wrong the script works I didn't copy I would actually recommend printf (in the modern versions of ksh which have it), because it's portable across shells. –Mark Reed Oct 5 at 13:47 add a comment| Your Answer June 21, 2005 - 8:32 am UTC Reviewer: A reader Tom, This is not an Oracle question, but since your knowledge goes much beyond Oracle, I am asking.

Bash Get Return Code Of Last Command

will always return '0' which is not I want ...Take a closer look at my example ...-Shabu 0 Kudos Reply KapilRaj Honored Contributor Options Mark as New Bookmark Subscribe Subscribe to http://www.softsource.com.sg/2012/02/02/scripting-tips-1/ You can do any shell processing in between sql queries. Ksh Exit Thanks Ashish Followup April 24, 2012 - 7:44 am UTC seems like a windoze (they do \r\n for end of lines) versus unix (they do a \n for end of lines) Bash Assign Exit Code To Variable cat $tempout | tee -a logfile rm $tempout if [ $err -ne 0 ] ...

SP2-0044: For a list of known commands enter HELP and to leave enter EXIT. That would involve chopping up string that could vary in length. Check out the awesome new features. If grep found something it will return 0 else 1. Ksh Eval

Thanks. My LOG_TABLE table is as shown below - CREATE TABLE LOG_TABLE ( STEP_ID NUMBER NOT NULL, SUB_STEP_ID NUMBER NOT NULL, SCRIPT_TYPE VARCHAR2(100), SCRIPT VARCHAR2(1000), PROCEDURE_CALL VARCHAR2(4000), EVENT VARCHAR2(20), PROCESS_TABLE VARCHAR2(100), ROW_COUNT gio123bg Shell Programming and Scripting 4 12-15-2003 10:21 AM All times are GMT -4. check over here in0) echo " Action is not available" ;;1) echo " Action is start" ;;2) echo " Action is shutdown" ;;3) echo " Action is end" ;;esacThere is no need for RC

Unix Home: Unix System Administration Hints and Tips ≡ MenuHomeAboutLinux Shell Scripting TutoriaLRSS/FeednixCraftLinux and Unix tutorials for new and seasoned sysadmin.Shell: How to determine the exit status of Linux and UNIX Ksh Tutorial I had tested with KSH/BASH. Depending on program $SCRIPT, have you thought about checking stderr?

How do manufacturers detune engines?

Browse other questions tagged bash unix ksh exit or ask your own question. Not the answer you're looking for? February 27, 2007 - 2:37 pm UTC Reviewer: Alexander the ok Yes I can, thanks that was the issue though. Bash Pipestatus UNIX is a registered trademark of The Open Group.

it seams that the direct call of read is more robust than the use of backsticks in ksh.when i use the follwing code for your example, i din't had a problem: I wanted to capture all the actions that happens in the shell script like calling shell function to download file, loading data using sqlloader, shell function which calls pl/sql package, actions Thank you!! echo $child_return_code This $?

Reply Link tuh July 12, 2011, 5:45 pmMaybe Chris will see this, or maybe not. Asked: July 14, 2000 - 10:07 am UTC Answered by: Tom Kyte – Last updated: October 18, 2012 - 8:40 am UTC Category: Database – Version: 8.1.5 Application Express 5.1 is You are all great and making this into a very valuable knowledge source. The code is as shown below.

Reply Link M P November 9, 2010, 1:23 pmVery helpful. in the parent script will have the return code as per the above. Ex: $ SAL=`sqlplus scott/tiger -s << select max(sal) from emp; exit; EOF Thanks, Bhaskara and we said... Forgot the eval: SCRIPT=w cmd="$SCRIPT 2> err.file |tee -a log.file" eval $cmd TMTOWTDI my preference: (. $SCRIPT $DIVN ; echo $? >RES)| tee -a $LOGFILE export ERR=$(cat RES) Try

This is because the assignment of the value of $? Can you explain the exit status of shell and commands under Linux / UNIX operating system? this is useless here as our script doesn't output anything on stderr but it can come in handy with other scripts. Forum Operations by The UNIX and Linux Forums Home News About Us Company Profile Why Softsource?

if [ $OUT -eq 0 ];then echo "User account found!" else echo "User account does not exists in /etc/passwd file!" fiSave and execute the script as follows: $ chmod +x script.sh