|
|
Unable to execute shell script
Hi,
I have a shell script written for ksh. Its execution permissions are
correctly set for the current
user. and the PATH also includes the entry for "."(current directory).
But still i am not able to run the script from the command prompt.
When I do myscript.sh or ./myscript.sh it says "file not found:
myscript.sh". But the file is there in the current directory.
Please help me.
Thanks in advance.
Gana
|
|
0
|
|
|
|
Reply
|
ganesh.m (9)
|
12/21/2005 1:35:30 PM |
|
Do you have the correct/format for ksh on the first line of the script?
ganesh.m@gmail.com wrote:
> Hi,
>
> I have a shell script written for ksh. Its execution permissions are
> correctly set for the current
> user. and the PATH also includes the entry for "."(current directory).
> But still i am not able to run the script from the command prompt.
>
> When I do myscript.sh or ./myscript.sh it says "file not found:
> myscript.sh". But the file is there in the current directory.
>
> Please help me.
>
> Thanks in advance.
> Gana
|
|
0
|
|
|
|
Reply
|
vanospam
|
12/21/2005 1:44:01 PM
|
|
agreed, double-check the shebang line. chances are the path is not
correct. for example, your shebang line might be something like,
!#/usr/bin/ksh
however, on your system ksh is not installed at that path. double
check the path to the shell and make sure the shebang line reflects the
accurate path.
hope to have helped!
kind regards,
chris
|
|
0
|
|
|
|
Reply
|
chris
|
12/21/2005 1:53:33 PM
|
|
What does an ls -la show of that directory? Maybe there is an extra
char in the file name etc...
|
|
0
|
|
|
|
Reply
|
Dave
|
12/21/2005 1:55:41 PM
|
|
ganesh.m@gmail.com writes:
>I have a shell script written for ksh. Its execution permissions are
>correctly set for the current
>user. and the PATH also includes the entry for "."(current directory).
>But still i am not able to run the script from the command prompt.
>When I do myscript.sh or ./myscript.sh it says "file not found:
>myscript.sh". But the file is there in the current directory.
What's the first line of the script?
Casper
|
|
0
|
|
|
|
Reply
|
Casper
|
12/21/2005 2:03:50 PM
|
|
Oh...
Sorry for wasting your time...
Fixed the problem. My file was in dos format. converted it to unix and
it worked.
Thank you all for your kind reply.
|
|
0
|
|
|
|
Reply
|
ganesh
|
12/21/2005 2:13:22 PM
|
|
In article <1135174402.091464.26120@g14g2000cwa.googlegroups.com>,
ganesh.m@gmail.com writes:
|> Oh...
|> Sorry for wasting your time...
|> Fixed the problem. My file was in dos format. converted it to unix and
|> it worked.
Ah. The dreaded invisible CR.
If Unices (and Solaris is normal here) produced a slightly less
cretinous error message in the case of an interpreter problem,
there would be a lot less wasted time.
Regards,
Nick Maclaren.
|
|
0
|
|
|
|
Reply
|
nmm1
|
12/21/2005 2:17:26 PM
|
|
In <1135172130.684451.38830@o13g2000cwo.googlegroups.com> ganesh.m@gmail.com writes:
>I have a shell script written for ksh. Its execution permissions are
>correctly set for the current
>user. and the PATH also includes the entry for "."(current directory).
>But still i am not able to run the script from the command prompt.
>When I do myscript.sh or ./myscript.sh it says "file not found:
>myscript.sh". But the file is there in the current directory.
The usual reason for this behavior is that the file has DOS
line endings. You can use the `dos2unix' command to create a
copy that has the correct line endings.
--
-Gary Mills- -Unix Support- -U of M Academic Computing and Networking-
|
|
0
|
|
|
|
Reply
|
Gary
|
12/21/2005 2:20:45 PM
|
|
chris.sentman@gmail.com wrote:
> agreed, double-check the shebang line. chances are the path is not
> correct. for example, your shebang line might be something like,
>
> !#/usr/bin/ksh
>
.......
Better #!/bin/ksh or #!/usr/bin/ksh
--
Gruss
Robert
|
|
0
|
|
|
|
Reply
|
Robert
|
12/21/2005 3:06:52 PM
|
|
ugh, yeah... much better. ;)
thanks for the correction.
kind regards,
chris
|
|
0
|
|
|
|
Reply
|
chris
|
12/21/2005 3:50:50 PM
|
|
ganesh.m@gmail.com writes:
> I have a shell script written for ksh. Its execution permissions are
> correctly set for the current
> user. and the PATH also includes the entry for "."(current directory).
Having "." in your $PATH is a bad idea.
Suppose you cd into somebody else's directory and try to run "ls" --
but they've installed an "ls" script in that directory that does
"rm -rf $HOME".
Putting "." at the end of your $PATH can avoid that problem, but it's
still not recommended. Suppose you name a script "test". The command
"test" won't do what you expect.
My advice: remove "." from your $PATH and get into the habit of typing
"./foo" if you want to run something in the current directory.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
|
|
0
|
|
|
|
Reply
|
Keith
|
12/22/2005 1:37:15 AM
|
|
Nick Maclaren wrote:
>In article <1135174402.091464.26120@g14g2000cwa.googlegroups.com>,
>ganesh.m@gmail.com writes:
>|> Oh...
>|> Sorry for wasting your time...
>|> Fixed the problem. My file was in dos format. converted it to unix and
>|> it worked.
>
>Ah. The dreaded invisible CR.
>
>If Unices (and Solaris is normal here) produced a slightly less
>cretinous error message in the case of an interpreter problem,
>there would be a lot less wasted time.
>
>
>Regards,
>Nick Maclaren.
>
>
For some reason the esthetics of Unix and useful error messages seem to
be in compatible!
|
|
0
|
|
|
|
Reply
|
Richard
|
12/23/2005 12:33:25 AM
|
|
In article <dobo5m$q97$1@gemini.csx.cam.ac.uk>,
nmm1@cus.cam.ac.uk (Nick Maclaren) writes:
> Ah. The dreaded invisible CR.
>
> If Unices (and Solaris is normal here) produced a slightly less
> cretinous error message in the case of an interpreter problem,
> there would be a lot less wasted time.
In this area, sparc and x86 should really both learn
to recognise each other's executable format so they can
return EINVAL on the exec(2) call rather than giving them
to a shell to fall over.
Mind you, the old "not a typewriter" used to bring a smile
to my face. ;-)
--
Andrew Gabriel
|
|
0
|
|
|
|
Reply
|
andrew
|
12/23/2005 1:00:00 AM
|
|
andrew@a17 (Andrew Gabriel) writes:
>In this area, sparc and x86 should really both learn
>to recognise each other's executable format so they can
>return EINVAL on the exec(2) call rather than giving them
>to a shell to fall over.
Isn't that what happens?
BTW, the failing over is done by the shell and not the kernel
so it's something that needs to be fixed in every shell.
The shell tries the exec and if the exec fails it will then
run it in a shell. (And exec does appear to return EINVAL
for the ELF binaries I tried in snv_30/29)
Casper
|
|
0
|
|
|
|
Reply
|
Casper
|
12/23/2005 9:19:32 AM
|
|
|
13 Replies
578 Views
(page loaded in 0.145 seconds)
|
|
|
|
|
|
|
|
|