Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 04-09-2005, 05:09 AM   #1
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Rep: Reputation: 15
Starting a program from a shell script

Hey guys,

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

ping -c 2
if [$? !=0] ; then
wol --host= 90:50:A1:EF0:53
echo "Starting up Host"
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= 90:50:A1:EF0:53

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


Old 04-09-2005, 08:06 AM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Are you getting an error when you try to run the script? Perhaps you could tell us what it is.
Old 04-17-2005, 12:16 AM   #3
Registered: Jul 2004
Location: Rio de Janeiro - Brazil
Distribution: Conectiva 10 - Conectiva 8 - Slackware 9 - starting with LFS
Posts: 519

Rep: Reputation: 34
Hi Suinatsa,
Looking your script, I guess it is logically correct. However, you must get a syntax error in the line:
if [$? !=0]
The character "[" is a symbolic link to /usr/bin/test. If you read "man test", you'll see:
1 - when using the alternative "[" "]" you have to separate both the brackets by space;
2 - numerical comparisons are specified by "-eq" for "equal to", "-neĻ for "not equal to".
So, this line should be:
if [ $? -ne 0 ]; then
I don't know the "wol" command but, the syntax is the same as you use in interactive mode.




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
a script run through a shell program... okeyla Linux - Newbie 1 09-15-2005 10:06 AM
how to cll shell script from c program mili Programming 3 04-27-2005 11:22 AM
call a c program in a shell script jagman Programming 4 04-05-2005 04:58 PM
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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:33 AM.

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