Operating System - Linux
1827909 Members
2588 Online
109971 Solutions
New Discussion

-e option not working in ksh!!!!

 
SOLVED
Go to solution

-e option not working in ksh!!!!

Hi i have the following version of ksh
Version 11/16/88

i am trying a basic script
#!/usr/bin/ksh
set -x
filename="test.ksh"
echo "File name is " $filename
if [[ -e $filename ]]
then
echo "exists"
fi


but the script is giving an error
[tidrfx1g]nemana/ksh $ ./t1.ksh
+ filename=test.ksh
+ echo File name is test.ksh
File name is test.ksh
./t1.ksh[4]: syntax error at line 6 : `$filename' unexpected


i tried -f option.. it is working...

is this a problem with the version i have? Please help me..

Thanks in anticipation,
Satya Prasad
Patience pays....but you will need pateince for that........
8 REPLIES 8
Steven E. Protter
Exalted Contributor

Re: -e option not working in ksh!!!!

Shalom Satya,

Either your script isn't runing in the directory the file is supposed to be in or:

You may have a bug. There have been several patches to posix and korn shell over the years. I'd have them in anyway.

However, I favor the first paragraph of this post as the culprit.

ll > file.list
echo $filename >> file.list

right before the dash e statement and see if you are where you think you are.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com

Re: -e option not working in ksh!!!!

Steven,

i doubt the first part....the version of the ksh which is the culprit as the same script with -e changed to -f worked.

i tried adding the lines to the script..

ll > file.list
echo $filename >> file.list

and observed the same result.
Patience pays....but you will need pateince for that........
V. Nyga
Honored Contributor
Solution

Re: -e option not working in ksh!!!!

Hi,

it seems like -e doesn't exist as an option.
See:
http://www.context-switch.com/reference/kshref/ch4.html

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
V. Nyga
Honored Contributor

Re: -e option not working in ksh!!!!

Do you wanna use -a option?
*** Say 'Thanks' with Kudos ***

Re: -e option not working in ksh!!!!

Hi Volkmar

You are correct.

In the following reference, i see the -e option.

http://www.cs.princeton.edu/~jlk/kornshell/doc/man93.html

But in the man page of year 88,
http://www.cs.princeton.edu/~jlk/kornshell/doc/man88.html
i dont,

which i guess is the current version i have on my system.

Thank you very much for the help...

Regards,
Satya Prasad


Patience pays....but you will need pateince for that........

Re: -e option not working in ksh!!!!

Thank you for your valuable time.
Patience pays....but you will need pateince for that........
James R. Ferguson
Acclaimed Contributor

Re: -e option not working in ksh!!!!

Hi Satya:

Since this is HP-UX why not use the POSIX shell --- the HP-UX standard shell in '/usr/bin/sh'?

This is wholly 'ksh' with full POSIX support.

Otherwise, you could use the Korn93 shell found in '/usr/dt/bin/dtksh'.

Substituting either interpreter ('/usr/bin/sh' or '/usr/dt/bin/dtksh' for '/usr/bin/ksh' will offer you a working script.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: -e option not working in ksh!!!!

You could also use -a, that works for sh and ksh.