View: 2742|Reply: 8
|
Shell programming for UNIX
[Copy link]
|
|
Salam,
Anybody knows bout shell programming/scripting? I can't find a good place to learn. I wanna automize some system admin jobs like script for checking hd space etc.
TQ in advance |
|
|
|
|
|
|
|
tell me in details, I will try to help........... |
|
|
|
|
|
|
|
Done googling. Getting more headache than info. As my experience in programming is just some simple scripting for ASP, this is a bit hard for me.
My goal is pretty simple. Everyday i want to check free hard disk space and check some processes (application and database), get the output in a webpage most probably using Apache/php so that i don't need to login to the server everyday and run the command manually.
Currently what I have in mind is to used a cronjobs by specifying the command directly like bdf/df -k/ ps -ef and put it in text file. As i'm managing HP UX and Solaris, so the command used most probably will be different. But integrating all of them in one script is what I want so I will only run one script everyday using cron. After that, the output should be available via web. Sound simple but to a novice like me it seems like hiking Everest.
If anybody is kind enough to teach me, it'll be great. Clues are also appreciated :tq: |
|
|
|
|
|
|
|
if using php, can use shell_exec http://www.php.net/shell_exec
but from what u want is a simple bash script also can, but for connecting via web better php/apache .. it can be done, I did it b4 but now bz can't help u much |
|
|
|
|
|
|
|
Thanks for the tips. Will read it through first. It's quite long :tq: |
|
|
|
|
|
|
|
correct, just use a cron job.
instead of writing to a 'nowhere' text file, just write directly to the www root of Apache, and then you can see it daily. perhaps you could do something nifty such as write the filename as the date when the script is run... e.g run script of 24/6/06... so filename is result_2006_06_06.htm... for example....
about different OS... yes there will be differences... there's no easy way around it.. you will see a lof of scripts which seems 'integrated/multi-platform', but they will have checks for different OSes.
like
if OS is solaris
do this solaris-specific command
else if OS is HPUX
do this instead
bla bla .... i think u get the drift... finally once u check for everything, yes, this is your 'ONE' true script. u can put it on any OS.
but usually, if it's unix-based, it won't differ that much (*hopefully*). try around with the commands (df/du), they should work *almost* the same.
gluck... |
|
|
|
|
|
|
|
that is a nice idea - writing the output directly to the www root directly. but wouldn't the output format will be different? I mean will it be readable? I did a test by using telnet, get the output to a text file in windows and it seems a bit unreadable when i convert it to html as it need some remaking so that the output will be readable. Or can i reformat the output like putting it in table form something like that?
TQ |
|
|
|
|
|
|
|
Originally posted by kroeGand at 29-8-2006 10:06 PM
that is a nice idea - writing the output directly to the www root directly. but wouldn't the output format will be different? I mean will it be readable? I did a test by using telnet, get the outpu ...
oh.. just make sure when you write it, you write it in html format... as in result.html... and do proper HTML 'coding'...
like
<HTML>
<bla bla bla>
<TABLE>
put your result here in <TR> and <TD> bla bla
</TABLE>
</HTML>
done!
gluck! |
|
|
|
|
|
|
| |
|