- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Ksh script calling Csh script !!
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2003 05:36 AM
04-29-2003 05:36 AM
Ksh script calling Csh script !!
Because of some political issue, I need to write a Ksh menu program to call some Csh scripts.....
However, I have difficulties to get the return code returned by Csh.....
Could anyone give me some examples for this question !
Many thanks,
Chris,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2003 05:50 AM
04-29-2003 05:50 AM
Re: Ksh script calling Csh script !!
I just tried out this -
$ cat /tmp/a.sh
#!/usr/bin/ksh
csh c.sh
if [[ $? -eq 0 ]]; then
echo "c.sh exited with 0 return value"
else
echo "c.sh exited with non-zero return value"
fi
# EOF
$ cat /tmp/c.sh
#!/usr/bin/csh
exit 1
# EOF
I am able to get the return values perfectly when i run a.sh with the call to c.sh as follows -
/tmp/c.sh or csh /tmp/c.sh.
It'd probably help if you could attach the scripts here.
HTH.
- ramd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2003 06:01 AM
04-29-2003 06:01 AM
Re: Ksh script calling Csh script !!
$? will return all exit codes.
however if your c.sh script return more values such as variables.
then you want to consider this
c.sh | read LINE
echo $LINE
then you you can work from there.
one of my c.sh scripts for instance return 18 variables.
in ksh you can read them as
c.sh | read VAR[0] VAR[1] ... VAR[17]
echo $VAR[*] or echo $VAR[@]
l8r
peace
Donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2003 06:03 AM
04-29-2003 06:03 AM
Re: Ksh script calling Csh script !!
'crontab' is csh for example.
Got any lines in between the executing command and the test?
Try this:
command1
STAT1=$?
command2
STAT2=$?
etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2003 06:14 AM
04-29-2003 06:14 AM
Re: Ksh script calling Csh script !!
#!/usr/bin/csh
...csh code...
or
#!/usr/bin/ksh
#!/opt/perl/bin/perl
and so on.
Note that there is only ONE return code for any process or script, the numeric value returned when it finishes (and accessible via $? in ksh or other POSIX shells). For additional values, the script must output these values as stdout or stderr and the calling script read these values.
If the csh scripts change the environment by setting certain variables, these scripts must be rewritten to return the changes as stdout or stderr since executing a script in place (called 'sourcing' by using the dot . shell construct) requires the script to be written in the same language as the invoking shell (ksh in your case).
Bill Hassell, sysadmin