LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   script.sh - No such file or directory - ??? (https://www.linuxquestions.org/questions/programming-9/script-sh-no-such-file-or-directory-186004/)

ilhbutshm 05-26-2004 07:31 AM

script.sh - No such file or directory - ???
 
I wrote a lil script.sh that generates and echoes random integers. It worked, but somewhere along the way it stopped working. Dunno how and why.

When I write this into console: script.sh or ./script.sh or /usr/local/bin/script.sh all I get is this


/usr/local/bin/script.sh: line5: 50: No such file or directory.

What am I doing wrong? I'm going nuts here... I tried deleting it and copying it from my home dir back to usr/local/bin, I tried resetting the permission to 777, 755, none has worked.

If I try to rename it, or delete it, or edit it with VI, it works...it just wont execute.

b0uncer 05-26-2004 07:34 AM

doesn't

/usr/local/bin/script.sh: line5: 50: No such file or directory.

mean that in the script called script.sh is an error on line number 5, and the error's number or something is 50 and means "no such file or directory"...at least that's what I'd say about that :) so it means, as far as I can understand, that on the line 5 you try to use something that can't be found? so the problem is inside the script, not in it's place on filesystem or permissions..

ilhbutshm 05-26-2004 07:53 AM

#!/bin/bash

number=6
limit=50
while [ "$number" < "$limit" ]; do
number=$RANDOM
let "number %= $limit"
echo "$number"
sleep "$number"
done

this is the script... i really cant find any errors... but this is my first script.. ;)

keefaz 05-26-2004 08:51 AM

well I think $RANDOM is not initialized (it has no value)

[ edit ]
and the correct test operator is '-lt' not '<'
Code:

while [ "$number" -lt "$limit" ]; do ...

ilhbutshm 05-26-2004 09:32 AM

Silly me!! It works now like a charm. thx a lot!

I've got another question now:

can I exec .php files via bash? I suppose this should be done with httpd so php can be parsed, but i'm not really sure how to do that...

ilhbutshm 05-26-2004 10:26 AM

I found teh answ0r!

I just wrote "php" before the command... like this:

php /var/www/htdocs/script.php

and it worked! yay!


All times are GMT -5. The time now is 05:30 AM.