Operating System - HP-UX
1838682 Members
3721 Online
110128 Solutions
New Discussion

sending multiple commands to ksh not working in hp-ux

 
SOLVED
Go to solution
Mikael Viklund
Occasional Advisor

sending multiple commands to ksh not working in hp-ux

Hiyas all.

Im trying to port some of my scripts from tru64 to hp-ux, but I got stuck on a simple thing like this. If I do : ksh "cd / ; ls" in tru64 or in Solaris it gives me the listing for /, but in hp-ux it says: "ksh: cd / ; ls: cannot open"

Why is that so, and how can I fix it?
7 REPLIES 7
Robert-Jan Goossens_1
Honored Contributor

Re: sending multiple commands to ksh not working in hp-ux

You can use the sh

# sh "cd / ; ls"
Steve Steel
Honored Contributor

Re: sending multiple commands to ksh not working in hp-ux

Hi

ksh -c "cd / ; ls"

Then it knows its a command


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Victor BERRIDGE
Honored Contributor

Re: sending multiple commands to ksh not working in hp-ux

Hi,
What about:
ksh "$(cd /;ls)"

All the best
Victor
Sridhar Bhaskarla
Honored Contributor

Re: sending multiple commands to ksh not working in hp-ux

Hi Mikael,

Use '-c' option to specify a command or a set of commands.

ksh -c "cd /;ls"

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Fred Ruffet
Honored Contributor
Solution

Re: sending multiple commands to ksh not working in hp-ux

If you want to keep something like your old command, you will like :
ksh -c "cd / ; ls"
-c option tells ksh to run a command then exit.

Note that running
cd / ; ls
(without running a new ksh) will do the same thing.

Another thing, look at those man pages :
sh-bourne(1) Bourne Shell (/usr/old/bin/sh)
ksh(1) Korn Shell (/usr/bin/ksh)
sh-posix(1) POSIX Shell (/usr/bin/sh)

If you port from sun, you'd better use sh as it is posix shell, as ksh on sun.

Regards,

Fred

--

"Reality is just a point of view." (P. K. D.)
Michael Schulte zur Sur
Honored Contributor

Re: sending multiple commands to ksh not working in hp-ux

Hi,

echo "cd / ; ls" | ksh
should do it too.

greetings,

Michael
Mikael Viklund
Occasional Advisor

Re: sending multiple commands to ksh not working in hp-ux

Thanks all for replying. ksh -c did the trick for me.