What is the best way to get a variable from another server with a shell script?
What is the best way to get a variable from another server with a shell script?
IE. Can I have domain.com/var.txt and var.txt contains either a 0 or a 1 and then have a shell script run every 5 minutes via crontab with the code as follows (so if var.txt contains a 1, dostuff.sh will execute): #!/bin/bash var = wget domain.com/var.txt if $var == 1 /root/dostuff.sh TIA! |
There are number of ways, using wget with option -O (as in OK) like this should be the easiest:
Code:
var=$(wget -O - http://domain.com/var.txt) [ More wget examples can be found @ http://www.editcorp.com/Personal/Lar...v1/wget_7.html ] Or you can use a python script like this to do the job: Code:
#!/usr/bin/env python |
Thanks!
I actually ended up doing it in perl: #!/usr/bin/perl $var=qx[wget -O - http://domain/var.txt]; if($var > 0){ qx[sh /root/dostuff.sh]; } |
All times are GMT -5. The time now is 06:44 AM. |