Sponsored Content
Top Forums Shell Programming and Scripting bash: executing commands and reading exit vals Post 302080381 by aigles on Tuesday 18th of July 2006 05:56:04 AM
Old 07-18-2006
Code:
func1()
{
    .....do stuff
    #echo "$EXIT_CODE"
    return $EXIT_CODE
}

if func1 $arg1 $arg2
then
   # func1 : succes (exit status 0)
else
   # func1 : error
fi

func1 $arg1 $arg2
if [ $? -eq 0 ]
then
   # func1 : succes (exit status 0)
else
   # func1 : error
fi

Jean-Pierre.

Last edited by aigles; 07-18-2006 at 11:54 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

2. UNIX for Dummies Questions & Answers

nohup - sub job in script not executing until I exit

My job is launched using this command: I'm at home and having VPN drops so I used nohup and background. nohup perf_mon -c rating_4_multi,cfg & The main script is PID 26119, and the sub task under it is 26118 which is not running - just sits there. 26119 runs forever but nothing else runs. I... (2 Replies)
Discussion started by: ido1957
2 Replies

3. Shell Programming and Scripting

Executing multiple processes without waiting for their exit status.

Hello Friends, Hope you are doing well. I just need a help in executing multiple processes. I've written a shell script which calls another scritps. But the problem is there are too many processes to run, and each process takes about a min to finish its execution. So, I want to just... (3 Replies)
Discussion started by: singh.chandan18
3 Replies

4. Shell Programming and Scripting

OSX, bash, cat with <<MARKER executing commands

I have a script that writes another script with cat >/usr/local/bin/myscript.sh <<EOF #!/bin/sh VAR=`run a command here` EOF Problem is, after this is run, I get: $ cat /usr/local/bin/myscript.sh #!/bin/sh VAR=result of command How do I stop that from happening with Macs... (2 Replies)
Discussion started by: jnojr
2 Replies

5. UNIX for Dummies Questions & Answers

Execute shell script and if string found while executing then exit

Hi All, I have one shell script start.sh which executes another shell script test.sh something like below :test.sh -param1 -param2 In the test.sh there is one command for removing file:rm file1.bak I want whenever I execute start.sh, it will execute test.sh and if it finds string rm... (7 Replies)
Discussion started by: ORAI
7 Replies

6. Shell Programming and Scripting

Executing 'exit' command from shell script

Hi, I am writing shell script to automate few use cases for CLI interface. We have CLI interface which has bunch of commands. I am trying to execute one of the commands 'exit' as part of automation to exit from CLI object (not from shell script) in my shell script. My intension is to execute... (4 Replies)
Discussion started by: Mahesh Desai
4 Replies

7. Programming

Fork and Execvp Not Executing Bash Commands From C correctly.

I had been looking at page 75 of this online book: http://richard.esplins.org/static/downloads/linux_book.pdf I've used the system function in C to call bash commands before, but wanted to learn this way too. The solution in the book worked perfectly. However, I tried changing the simple "ls -l... (3 Replies)
Discussion started by: Azrael
3 Replies

8. AIX

C Exit Not Executing

Greetings all, I am using an enterprise utility for document archiving. This program calls a custom C exit to do data manipulation before loading data into the archive. When the program is called via an automation script (Ran as ROOT), program successfully executes the C exit, and gives me an... (3 Replies)
Discussion started by: jeffs42885
3 Replies

9. Shell Programming and Scripting

Executing bash file with sudo for the second time, leads to permission denied, for some commands

I have a script that checks if the script has been ran with sudo. If the script is not ran as sudo, the current script is being executed with exec sudo bash. You are asked for a password, you type in the password, success. Everything is perfect - the commands inside the script are ran as sudo.... (1 Reply)
Discussion started by: boqsc
1 Replies
autouse(3perl)						 Perl Programmers Reference Guide					    autouse(3perl)

NAME
autouse - postpone load of modules until a function is used SYNOPSIS
use autouse 'Carp' => qw(carp croak); carp "this carp was predeclared and autoused "; DESCRIPTION
If the module "Module" is already loaded, then the declaration use autouse 'Module' => qw(func1 func2($;$)); is equivalent to use Module qw(func1 func2); if "Module" defines func2() with prototype "($;$)", and func1() has no prototypes. (At least if "Module" uses "Exporter"'s "import", otherwise it is a fatal error.) If the module "Module" is not loaded yet, then the above declaration declares functions func1() and func2() in the current package. When these functions are called, they load the package "Module" if needed, and substitute themselves with the correct definitions. WARNING
Using "autouse" will move important steps of your program's execution from compile time to runtime. This can o Break the execution of your program if the module you "autouse"d has some initialization which it expects to be done early. o hide bugs in your code since important checks (like correctness of prototypes) is moved from compile time to runtime. In particular, if the prototype you specified on "autouse" line is wrong, you will not find it out until the corresponding function is executed. This will be very unfortunate for functions which are not always called (note that for such functions "autouse"ing gives biggest win, for a workaround see below). To alleviate the second problem (partially) it is advised to write your scripts like this: use Module; use autouse Module => qw(carp($) croak(&$)); carp "this carp was predeclared and autoused "; The first line ensures that the errors in your argument specification are found early. When you ship your application you should comment out the first line, since it makes the second one useless. AUTHOR
Ilya Zakharevich (ilya@math.ohio-state.edu) SEE ALSO
perl(1). perl v5.14.2 2011-09-19 autouse(3perl)
All times are GMT -4. The time now is 03:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy