CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2742|Reply: 8

Shell programming for UNIX

[Copy link]
Post time 28-8-2006 02:41 PM | Show all posts |Read mode
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
Reply

Use magic Report


ADVERTISEMENT


Post time 28-8-2006 03:58 PM | Show all posts
google it, lotsa info
Reply

Use magic Report

Post time 28-8-2006 04:13 PM | Show all posts
tell me in details,  I will try to help...........
Reply

Use magic Report

 Author| Post time 28-8-2006 05:00 PM | Show all posts
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:
Reply

Use magic Report

Post time 28-8-2006 09:00 PM | Show all posts
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
Reply

Use magic Report

 Author| Post time 29-8-2006 01:44 PM | Show all posts
Thanks for the tips. Will read it through first. It's quite long :tq:
Reply

Use magic Report

Follow Us
Post time 29-8-2006 02:33 PM | Show all posts
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...
Reply

Use magic Report

 Author| Post time 29-8-2006 10:06 PM | Show all posts
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
Reply

Use magic Report


ADVERTISEMENT


Post time 29-8-2006 10:47 PM | Show all posts
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!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

16-1-2025 12:52 AM GMT+8 , Processed in 0.057618 second(s), 23 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list