OK, so I'm trying to set up a shell script that tests if TCP is working and then restarts if it is not... Since I need to remotely admin my OS X box and sometimes TCP/sshd dies, having this script running daily as a crontab item would be great. Because then the system would reboot if there is ever a problem. And there is more general applicability to these questions, as well...
Anyhow, I'm not totally clear on how I might do a few things:
1) How to do conditional stuff? (ie: if no TCP then restart)
2) How to get output from shell commands into variables? (Then parse it with awk, I assume...)
Or should I learn Perl to do this?
I know python and C pretty well, but I don't know how I can run and get output from shell commands from within C or python programs... Does anyone else know this?
If anyone can answer my questions, that would be great. If anyone has a good link to a primer on shell scripting in general, I would be overjoyed.
Thanks,
Zach
Anyhow, I'm not totally clear on how I might do a few things:
1) How to do conditional stuff? (ie: if no TCP then restart)
2) How to get output from shell commands into variables? (Then parse it with awk, I assume...)
Or should I learn Perl to do this?
I know python and C pretty well, but I don't know how I can run and get output from shell commands from within C or python programs... Does anyone else know this?
If anyone can answer my questions, that would be great. If anyone has a good link to a primer on shell scripting in general, I would be overjoyed.
Thanks,
Zach