Operating System - HP-UX
1847177 Members
5398 Online
110263 Solutions
New Discussion

Re: scripting in C ?? this post ..

 
SOLVED
Go to solution
someone_4
Honored Contributor

scripting in C ?? this post ..

can you write scripts or programs for HPUX in C ? and can someone give me an example of one and how it would be usefull for a system admin? thanks
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: scripting in C ?? this post ..

Hi Richard,

Yes you can write sys admin scripts in C. One usually does it: a) to conceal what the script is doing and prevent users from altering simple shell scriptsa b) to do things at a very low level (like flushing ports, setting special tty parameters, having precise control of a process, querying hardware, etc.) c) to maximize execution speed; or d) to grant great power to a command. I've attached a powerful sudo like command that can execute any command as any user/group. This program takes advantage of the setuid/setgid features. If compiled and owned by root with permissions 6755 then this guy can execute anything. I don't say that this is a good example (or safe) but it does illustrate the power of a c program.

For most complicated scripts, I find that perl is the weapon of choice. It allows you to do thing like socket communication between machines (The machines might not even be unix boxes.) Essentially anything you can do with a combination of shell, awk, grep, and sed (and to a degree with c), you can do with perl.

Hope this helps, Clay
If it ain't broke, I can fix that.