1828669 Members
2638 Online
109984 Solutions
New Discussion

Shell script help wanted

 
Chang_6
Regular Advisor

Shell script help wanted

I am supposed to write an script that does some tasks like below:

Can somebody please help me what kind of scripting language I should use? Should it be perl or Shell scripting? I think there is also some "awk" work. The shell that I am using is bourne/hp-ux. So, how do I know if bourne supports all the features? There could be some more tasks in future. What is the best way to implement it? Some of the portions may be reuseable. Could you please comment if there is anything that cannot be done (from below)?

Here are some tasks:

Monitor disk space, Notify (via email) when something wrong (bdf -bi)
Monitor free blocks via unix, Notify (via email)when something wrong (df -k)
select count(*) from a few tables in oracle, notify (via email)when something wrong
Changing file name extension (file name extension has a number that needs to be calculated)
Moving files to a different directory
Monitor processes .. ( 3 processes must always be running otherwise notify (via email))
Search a file for keywords (Need to monitor the content of file)
Creating a file
killing processes
su as root, (some notifications depending on condition)
issue a command
check date and time on processes
issue ls -l, if files with .XXX ext'n are found, notify
change dir, if files older than today, notify

I would greatly appreciate any suggestions/comments/questions from you.
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: Shell script help wanted

You could handle these with shell scripting and or perl scripts.

I'm attaching a tar file with a few starter scripts that will give you a base with which to start your process.

See attachment.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: Shell script help wanted

Its mostly been done before.

Check out this man's past questions:
http://forums1.itrc.hp.com/service/forums/publicProfile.do?userId=BR180643&forumId=1

He has three threads filled with scripts that sysadmins can't live without.

Almost everything you are looking for is in those threads.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
A. Clay Stephenson
Acclaimed Contributor

Re: Shell script help wanted

Unless you go to great lengths, you are not running the Bourne shell under HP-UX, you are using the POSIX shell which is essentially the Korn shell and is rather fully featured.

The answer to your question probably a mixture of all three. If I were forced to choose only one my answer would be Perl but the learning curve is the steepest.
If it ain't broke, I can fix that.
Steve Steel
Honored Contributor

Re: Shell script help wanted

Hi


This is a cool site

http://www.shelldorado.com/

Heiner's SHELLdorado
SHELLdorado - your UNIX shell scripting resource


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Elmar P. Kolkman
Honored Contributor

Re: Shell script help wanted

Choosing a 'language' is a hard task.
For instance, your performance is best if you write it efficiently in C. But there a fewer people available to maintain C programs nowadays.
And writing as a shell script is probably on of the slowest solutions, but is more portable across hardware and unix versions. And since the commands in a shell script are the same as on the prompt, they are more accessible by other sysadmins.

So, if you're the only one maintaining the scripts in the coming years, your choice is free. But if you are part of a sysadmin organization and others have to maintain and understand what you have done, your choice is limited to the general knowledge within the organization.

As for the monitoring it self: I would go for specific programs for the specific monitoring, perhaps with a general include file containing functions that make the writing more easy. Then you can start those programs from cron, for instance.

Just my 2 cents.
Every problem has at least one solution. Only some solutions are harder to find.