ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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!
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,786
Rep:
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.
/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
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)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.