script to return value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to return value
# 1  
Old 01-24-2007
script to return value

I have 3 scripts

script A - wrapper script to disguise invoker true identity

script B - perform database operation and return a value (either W/H)
-> return value by echoing the result

script C - use script A to mask as the database owner then invoke script B to retrieve the value
-> /sys1/proclib/wrapper.sh dbadmin status.sh

I want to store the result in a variable, hence, status=`/sys1/proclib/wrapper.sh dbadmin status.sh`
but the result that I got back is actually "[YOU HAVE NEW MAIL] P" instead of just "P".

I found out that when script A is invoked, it would automatically echo "[YOU HAVE NEW MAIL]" to stdout.
All I want to be able to get the result from script B, anyone can help? Thanks!
# 2  
Old 01-24-2007
Just trying to get what your on about...

You run Script C, which runs Script A which runs Script B
How Script B echos either a W or a H when complete.

And you want to know this when script c ends....correct????

If thats the case try this (It may need testing....as there are other ways to trap stuff)

Inside the scripts try this

set a variable to the running of each script.

ie

ScriptC
end_scriptA=`/path/to/scriptA`
echo $end_scriptA

ScriptA
end_scriptB=`/path/to/scriptB`
echo $end_scriptB

There are better ways by using the $?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Return: can only `return' from a function or sourced script

Not sure where the problem is. I can run the script without any issue using the following command. . /opt/app/scripts/cdc_migration.sh But it fails with the below error when I try it this way /opt/app/scripts/cdc_migration.sh /opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies

2. Shell Programming and Scripting

Need output of script on screen and file with correct return status of the called script.

Hi, I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed. Below is my sample... (14 Replies)
Discussion started by: Prathmesh
14 Replies

3. Shell Programming and Scripting

Doing a tail in a script and then return back and continue script

Hello all, I am trying to do a tail in a script. But when I quit the tail my script quits also. This is not what I want. I am struggling to get this done. #!/bin/bash askFile() { echo -n "Enter file: " read FILE } doTail() { tail -F "${1}" } askFile doTail... (4 Replies)
Discussion started by: markdark
4 Replies

4. Shell Programming and Scripting

How to return a value from another script

Hi! I have a parameter in an existing script, let's call the parameter param1 and the script - script1. I have another script - script2, which receives param1 and returns a certain value. I would like this value to be returned inside param1. There is no problem with script2, it runs... (5 Replies)
Discussion started by: shira
5 Replies

5. Shell Programming and Scripting

How to return a value of a variable from shell script to perl script

HI , Is there any way to return a value of variable from shell to perl script. Code: === Perl file my $diff1=system("sh diff.sh"); my $diff2=system("sh diff1.sh"); I need exit status of below commands i.e 0 and 1 respectively. Since in both the cases diff is working so system... (3 Replies)
Discussion started by: srkelect
3 Replies

6. Shell Programming and Scripting

How to return the value from the called shell script to the calling sh script

Hi all, I have two ksh scripts #sample1.sh #!/bin/ksh . ./sample2.sh echo $fileExist #sample2.sh #!/bin/ksh func() { i=1 return $a } func echo $? Here how should I return the value of sample2.sh back to sample1.sh? Thanks in advance. (2 Replies)
Discussion started by: gp_singh
2 Replies

7. Shell Programming and Scripting

how ro use return from a child script

I use return <value> to return a value from inside an else condition in child script to parent script and i am getting the following error.What is this sourced script? Can I return value to a different script using return statement. return: can only `return' from a function or sourced script (1 Reply)
Discussion started by: codeman007
1 Replies

8. Shell Programming and Scripting

How to know return value of the script

I have a script and when it is running it is showing PASSED or FAILED.But I would like to pass the results into return code.So pls provide suggession how to add return code into this script AgcfIp=`GetSoftatcValue AgcfIp_1` AgcfShell=`GetSoftatcValue AgcfShell_1` AgcfPath=`GetSoftatcValue... (2 Replies)
Discussion started by: madhusmita
2 Replies

9. 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

10. Shell Programming and Scripting

return valuse from child script to parent script

Hi, I am trying to return a value from child script to a parent script just as a function does. The child script will look for a file and if exists will return 1 else 0. I need to capture the status 1 from child script in the parent script and proceed further. if 0, i need not do... (1 Reply)
Discussion started by: borncrazy
1 Replies
Login or Register to Ask a Question