LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   running a program from shell script (http://www.linuxquestions.org/questions/programming-9/running-a-program-from-shell-script-311351/)

Suinatsa 04-09-2005 06:07 AM

running a program from shell script
 
Hey guys,

I have been trying to write a shell script which is able to run a little programm.

ping -c 2 192.168.1.51
if [$? !=0] ; then
wol --host=192.168.1.1 90:50:A1:EF:D0:53
echo "Starting up Host"
fi
Thats what I got so far. What I want to do is that the script pings one of my computers in my network.
Whenever it fails I want the script to start the program "wol" which starts up the remote computer by the wake on lan function.

I am a noob in shell programming so it is a minor error most probably. I guess the line

wol --host=192.168.1.1 90:50:A1:EF:D0:53

has to be different. It is the whole command which has to be executed.

Thx

Suinatsa

jlliagre 04-09-2005 07:12 AM

You do not need to post your question twice but you need to tell us what the problem is !

Suinatsa 04-10-2005 03:59 PM

Hey,

I am sorry for double posting. My firefox had some trouble sending my post!

The problem is that whenever I execute the script it says

line 4 command not found. Line 4 is
wol --host=192.168.1.1 90:50:A1:EF:D0:53

Thx

Suinatsa

jlliagre 04-10-2005 06:30 PM

Is this bash scripting ?
Isn't the real error message:
"wol: command not found"
Assuming int, the "wol" command is either missing or not in the path.

Suinatsa 04-13-2005 12:50 PM

Hey

yeah it is a bash script.

And you are right it cannot find the command. I just want to know how I write a sript that can execute a program.

When I type "wol" in the command line it executes the programm "wol".
Do I have to specify the path of the programm or what?

Thx

Suinatsa

jlliagre 04-13-2005 02:28 PM

Quote:

When I type "wol" in the command line it executes the programm "wol".
what is your path ? (echo $PATH)
where/what is wol ? (type wol)
Quote:

Do I have to specify the path of the programm or what?
that's one possibility, another would be to set a correct PATH.

Suinatsa 04-14-2005 09:28 AM

Hey

ok wol is a program which uses the (w)ake (o)n (l)an function. Whenever you execute the program with some parameters it starts up a computer in a network.

What I want to do is that whenever I execute the script one computer in my network starts up.

I never specified anything for $path so it does not show me anything if I do echo $path.
Thats why I asekd if I have to do it!

Thx

Suinatsa

jlliagre 04-14-2005 09:49 AM

Quote:

ok wol is a program which uses the (w)ake (o)n (l)an function. Whenever you execute the program with some parameters it starts up a computer in a network.
I already know that, please answer my question which was:
run both of the following shell commands, and post their output:
Code:

echo $PATH
type wol

Quote:

What I want to do is that whenever I execute the script one computer in my network starts up.
You do not start the network, which must be already up, but really boot-up a connected host.
Quote:

I never specified anything for $path so it does not show me anything if I do echo $path.
Thats why I asekd if I have to do it!
I didn't asked you about $path but $PATH, which is usually set even if you're not aware of.

Suinatsa 04-14-2005 10:47 AM

Hey

I am sorry but I am a noob in shell coding!

Ok I ran the commands:

/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin:/opt/kde/bin:/usr/lib/qt/bin:/usr/share/texmf/bin
wol is /usr/local/bin/wol

Thats the output.

Thx

Suinatsa

deiussum 04-14-2005 12:02 PM

Are you running your script directly from the bash command prompt, or do you have it setup to run from something like a cron script. Usually the PATH variable that is set when running a cron script is different from a user's bash prompt. Explicitly specifying the path to wol might help. (e.g. /usr/local/bin/wol)

jlliagre 04-14-2005 12:25 PM

Can you post the whole script code too ?
Or add "echo $PATH" before the "wol" command is attempted and see if /usr/local/bin is there.


All times are GMT -5. The time now is 10:26 PM.