Solved [Solved] Cannot run script

fred974

Daemon

Reaction score: 37
Messages: 1,584

Hi guys,

I have written a script and made it executable but when I tried to run it I get the following:
Code:
./myscript.sh: not found
But if I do an ls , the file is there. I event tried to change the file to 777.

Could anyone help please?

I'm on FreeBSD 9.2 and my script starts with
Code:
#!/bin/sh
 

Beastie

Daemon

Reaction score: 502
Messages: 2,228

Re: Cannot run script

The error for the script not being executable is "permission denied".

I believe "not found" refers to a missing command inside the script.
 

ShelLuser

Son of Beastie

Reaction score: 1,732
Messages: 3,553

Re: Cannot run script

Check the first line of the script, the so called "she-bang". If that points to an invalid interpreter then you'll get the message which you described.
 
OP
OP
fred974

fred974

Daemon

Reaction score: 37
Messages: 1,584

Re: Cannot run script

Hi guys,

Thank you for the reply.

I just worked out after looking at the file in vi that I forgot to convert the ^M linebreak to 'normal' line break.

The problem has now been solved :)
 
OP
OP
fred974

fred974

Daemon

Reaction score: 37
Messages: 1,584

Re: Cannot run script

Moderators, how do I mark the post as solved?

Fred
 

fonz

Son of Beastie

Reaction score: 369
Messages: 2,560

Re: Cannot run script

fred974 said:
Moderators, how do I mark the post as solved?
Good question. We used to have a ready-to-go answer (edit the original post, select "go advanced" and select the prefix "[Solved]") but since the migration to the new forum software I'm not quite sure yet.
 

ShelLuser

Son of Beastie

Reaction score: 1,732
Messages: 3,553

Re: Cannot run script

Just an idea (not sure if this will work): Edit your first message in this thread and change the topic yourself (my suggestion would be to add "(solved)" (no "") in front of it).

At this moment that would be the easiest way I think.
 
Top