Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running command line utility using perl/cgi on remote machine

Status
Not open for further replies.

nivone

Programmer
Jul 2, 2002
33
IL
HI,

This is a tough one.
I use CGI with Perl.
I need to run a command line on a remote machine, actually it is a utility that gets some parameters. One of the parameters can be a file located where CGI runs.
Is it possible with Perl?
Maybe there is a different tool for that?

Thanks
 
Not quite sure what you trying to do here. If you're trying to find a file in a given (sub)directory then the recent addition to CPAN, File::Find::Rule is a great way to search for files.

Something like:

my @files = File::Find::Rule->file()->name( '*.mp3' )->in( '/MyMusic' );

Will recursively search and return all the mp3 files under the directory '/MyMusic'. If you're looking for a specific file enter that as the parameter to name(). All files listed in @files will be fully pathed.

Or did you mean you have a configuartion file that needs to be loaded with parameters? In which case if you create the contents of the file as set of Perl statements, you can do a 'require' to load-in the appropriate file. Barbie
Leader of Birmingham Perl Mongers
 
I will simplify things:
Machine A runs the web server with the perl scripts and html files.
User, on machine B (any machine on the domain) , runs the url to the application on machine A and supplies the name of machine C.
Machine C is installed with a utility that runs usually using command line.
What I'm looking for is a way to write Perl commands (or other tool) to run the utility on machine C.
 
Maybe you should get a script listening on a port of system C and connect if from a cgi-script in Machine B
If you will save some time by setting up a telnet server on machine C(probably more secure with password)
and you only have to make the script that connects to it.
 
You could create a crontab entry that runs a shell script. In that shell script you could check for the existence of a specific file. If the file doesn't exist the script dies, if it does exist it runs the command. Your script on machine A could then FTP a given file onto machine C and wait for the cron job to kick in.

In a previous job we had this senario, with the cron job checking every 10-15 minutes for an instruction file. Barbie
Leader of Birmingham Perl Mongers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top