LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-09-2005, 05:07 AM   #1
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Rep: Reputation: 15
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:EF0: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:EF0:53

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

Thx

Suinatsa
 
Old 04-09-2005, 06:12 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,486

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
You do not need to post your question twice but you need to tell us what the problem is !
 
Old 04-10-2005, 02:59 PM   #3
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

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

Thx

Suinatsa
 
Old 04-10-2005, 05:30 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,486

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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.
 
Old 04-13-2005, 11:50 AM   #5
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Original Poster
Rep: Reputation: 15
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
 
Old 04-13-2005, 01:28 PM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,486

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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.
 
Old 04-14-2005, 08:28 AM   #7
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Original Poster
Rep: Reputation: 15
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
 
Old 04-14-2005, 08:49 AM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,486

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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.
 
Old 04-14-2005, 09:47 AM   #9
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Original Poster
Rep: Reputation: 15
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
 
Old 04-14-2005, 11:02 AM   #10
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 31
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)
 
Old 04-14-2005, 11:25 AM   #11
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,486

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


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
Running shell script within a C or C++ program Quantum0726 Programming 2 06-15-2005 09:14 PM
Starting a program from a shell script Suinatsa Programming 2 04-17-2005 12:16 AM
Communication between shell script and program ZooL Programming 6 08-14-2004 05:44 AM
run shell script in c program u4u Linux - General 1 02-14-2004 02:48 PM
c/c++ running a shell script? thermalpants Programming 3 05-12-2002 11:41 AM


All times are GMT -5. The time now is 04:58 PM.

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