LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-26-2004, 08:31 AM   #1
ilhbutshm
Member
 
Registered: Jul 2003
Location: Europe
Distribution: Slackware 10.2
Posts: 104

Rep: Reputation: 15
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.
 
Old 05-26-2004, 08:34 AM   #2
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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..
 
Old 05-26-2004, 08:53 AM   #3
ilhbutshm
Member
 
Registered: Jul 2003
Location: Europe
Distribution: Slackware 10.2
Posts: 104

Original Poster
Rep: Reputation: 15
#!/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..

Last edited by ilhbutshm; 05-26-2004 at 08:57 AM.
 
Old 05-26-2004, 09:51 AM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
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 ...

Last edited by keefaz; 05-26-2004 at 09:56 AM.
 
Old 05-26-2004, 10:32 AM   #5
ilhbutshm
Member
 
Registered: Jul 2003
Location: Europe
Distribution: Slackware 10.2
Posts: 104

Original Poster
Rep: Reputation: 15
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...

Last edited by ilhbutshm; 05-26-2004 at 10:34 AM.
 
Old 05-26-2004, 11:26 AM   #6
ilhbutshm
Member
 
Registered: Jul 2003
Location: Europe
Distribution: Slackware 10.2
Posts: 104

Original Poster
Rep: Reputation: 15
I found teh answ0r!

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

php /var/www/htdocs/script.php

and it worked! yay!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to delete files with 0k file size in a directory justgiver Linux - Newbie 4 01-28-2008 05:56 AM
script execution - file/directory permission issue serksimper Linux - Enterprise 1 08-10-2005 04:01 PM
Shell script to copy file name with part of directory Transition Linux - General 5 01-18-2005 06:40 PM
Run script during file copy or create in directory neranjana Linux - General 1 01-13-2004 07:57 AM
Running a script on every file in a directory davee Linux - Newbie 2 11-04-2003 03:34 PM


All times are GMT -5. The time now is 09:48 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration