Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: run a perl script on a unix machine from a win machine

by graff (Chancellor)
on Dec 03, 2011 at 00:24 UTC ( [id://941462]=note: print w/replies, xml ) Need Help??


in reply to run a perl script on a unix machine from a win machine

What information from various unix/linux servers are you trying to get that isn't provided by "ls -l" ? Based on your code snippet, you're getting size, mod.date, and you want permissions too, and "ls -l" gives you all that (plus user and group ownership and link count).

If you have a list of servers to look at (e.g. in a file called "server.list" on your mswin machine), and a list of files to look for on each server (e.g. in separate files called "{servername}.filelist", also on the mswin machine), an easy way get what you want via a perl script on the mswin machine might be something like:

#!/usr/bin/perl # (standard shebang line, in case you get to use this on unix/linux so +meday) use strict; use warnings; open( SLIST, '<', "server.list" ) or die "server.list: $!\n"; while ( my $server = <SLIST>) { chomp $server; open( FLIST, '<', $server.filelist ) or do { warn "$server.filelist: $!\n"; next; } my $srvr_cmd = "ls -l"; while ( <FLIST> ) { chomp; $srvr_cmd .= " $_"; } my $file_info = `ssh $server $srvr_cmd`; print "=== results from $server ===\n$file_info\n"; }
You should be using a shell on the mswin machine that allows for redirection of stdout to a chosen file, or you can open an explicit output file in the perl script.

If you're trying to do something more complicated or subtle, and the above doesn't help with that, please be more explicit about what you're really trying to accomplish.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://941462]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-20 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found