Can perl do this ?

Forum: Programming and Scripting
Topic: Can perl do this ?
started by: manishsadh

Posted by manishsadh on Mar. 05 2007,10:04
Hi Folks,

i was wondering if perl scripting can help me do these things
on the monkey web server.

1 - create cron jobs and store them in crontab with root privileges

2 - create shell scripts and run them with with root privileges

3- run other shell commands and deamon's with root privileges


Posted by WDef on Mar. 05 2007,15:08
Not sure what you mean by "on" the Monkey web server.  Are you talking about wriiting applets or something to do these things from a secure remote web interface?
Posted by mikshaw on Mar. 05 2007,15:32
Theoretically, any task that can be done on the local machine can be done through a webserver on that same machine. If a Perl script can be written to create a cron job locally (which it can), then you could write a perl cgi script to do the same through a webserver on that machine.
An exception is if the server changes its filesystem root (chroot) when it runs, in order to limit remote access to sensitive files.
As far as tasks that require root, I think you are probably going to have problems. The webserver is typically run as a very limited user (nobody) to prevent unwanted access to system files. Giving this user permission to run as root basically destroys the whole concept of running as a limited user.  If you just want to have personal access to a remote machine through a browser, you *could* run the server as root, but I strongly recommend that you lock down the server to allow no unauthorized access (specifically, no access at all other than you).

Posted by Felson on Mar. 11 2007,21:54
There is an alternative.... Since you can't really make perl run stuf as root, you can make it write to a file that a cron job checks every minute or so.
So, the idea is, you make a root run cron that check to see if a file exists, if it does, do some action, and delete the file, if it doesn't, do nothing. Then you make a script that writes the file to the needed location.
ya, you have a useless cron running 99.99% of the time, but checking to see if a file exists isn't that expensive really.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.