- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: KSH script wrong behaviour
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
12-05-2001 01:37 AM
12-05-2001 01:37 AM
KSH script wrong behaviour
I'm using the KSH in HP-UX 10.20 on a HP B2000 machine.
In a KSH script A I call the function B (which is declared in a file executed in the header of A) then B calls the KSH script C.
It seems impossible but when C ended the control flow is returned not to B but to A.
A and C are different files.
B is a function contained in an environmental file which is executed before starting C.
It seems that A calls B (function) at line 100; B calls C at line 50 of B; when C ends the control returuns to A-line 101 rather than to B- line 51 ... The problem are:
* the instructions after B-line 50 are NOT executed
* the "$?" (return code) is undefined ... or better: it's 151 (what does it men??)
Have you any ideas?
thank you very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 01:49 AM
12-05-2001 01:49 AM
Re: KSH script wrong behaviour
I wasn't able to simulate your problem. Would you want to post your script up?
My test results are as follows. Notice that "echo d" gets executed when c.ksh finishes execution.
=============================
$ ./a.ksh
a
b
c
d
e
f
g
$ cat a.ksh
#!/usr/bin/ksh
a ()
{
echo b
c.ksh
echo d
}
echo a
a
echo e
echo f
echo g
$ cat c.ksh
echo c
===========================
Hope this helps. Regards.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 02:44 AM
12-05-2001 02:44 AM
Re: KSH script wrong behaviour
What do you mean by "environmental file"?
It is well known that if there is any erroneous command mentioned in a startup file (.profile / .login), further processing of the startup file is aborted.
Is your problem related to this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 03:55 AM
12-05-2001 03:55 AM
Re: KSH script wrong behaviour
It seems that when the B function is called and it executes a remsh, something strange happens then the remaining of B is not executed.
I enclose the source files: A = ManualSwitch
B = IsReachable, C = remoteCommand.
With "environmental file" I mean a file which is executed by the A / C scripts ... A starts executing B, which contains the relevant function (IsReachable)
thanks to everybody
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 05:09 AM
12-05-2001 05:09 AM
Re: KSH script wrong behaviour
In script C, try replacing "exit $rem_ret"
with
"return $rem_ret"
From the man page of exit,
"...exit() terminates the calling proces..."
Probably this is killing your ptocess B.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 05:25 AM
12-05-2001 05:25 AM
Re: KSH script wrong behaviour
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 05:53 AM
12-05-2001 05:53 AM
Re: KSH script wrong behaviour
You may want to look at putting the "-n" switch in your remsh command to stop it inadvertently sucking in input from your script.
This has often caused problems with scripts that remsh to other servers.
Rgds, Robin.