Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Running a cygwin command from within activestate

by WoodyWeaver (Monk)
on Mar 08, 2015 at 22:57 UTC ( [id://1119265]=perlquestion: print w/replies, xml ) Need Help??

WoodyWeaver has asked for the wisdom of the Perl Monks concerning the following question:

Patched cygwin to the latest versions and an rsync script stopped working. I'm running activestate perl as the primary engine, with cygwin also deployed. I have a perl script with
my $command = "c:\\cygwin64\\bin\\rsync.exe -ashv -e plink $user\@$host:/var/log/s +a/sar* ."; print "Executing $command\n" if $DEBUG; my $retval = `$command`;
However, this no longer does the right thing. If I create a bash script with
#!/bin/bash rsync.exe -ashv weaverw@ROMSXLVB2B102:/var/log/sa/sar* .
the right thing occurs (supplemented with ssh-pageant.) Is there a way programatically within perl to execute a command from within the cygwin environment? advTHANKSance, --woody

Replies are listed 'Best First'.
Re: Running a cygwin command from within activestate
by salva (Canon) on Mar 09, 2015 at 08:27 UTC
    when rsync is run from a bash script, shell metacharacters (i.e. wildcards) are expanded by bash in the UNIX fashion. On the other hand when you invoke rsync directly from Perl, it is called via cmd.exe that does the old MS-DOS expansion.

    You can probably use some program like ProcessMonitor to see the different set of arguments that rsync gets in every case.

Re: Running a cygwin command from within activestate
by AppleFritter (Vicar) on Mar 08, 2015 at 23:09 UTC

    and an rsync script stopped working.

    this no longer does the right thing.

    Could you elaborate?

      Simplest answer is outside of perl, since this seems to be a windows command shell thing. Before,
      C:\cygwin64\bin\rsync.exe -ashv -e plink --exclude=aide.log --exclude= +aide_error.log weaverw@10.3.30.149:/var/log/aide
      worked. Now,
      C:\Users\IBM_ADMIN>C:\cygwin64\bin\rsync.exe -ashv -e plink --exclude= +aide.log --exclude=aide_error.log weaverw@10.3.30.149:/var/log/aide Unable to read from standard input: The parameter is incorrect. rsync: safe_read failed to read 4 bytes [Receiver]: Connection reset b +y peer (104) rsync error: error in rsync protocol data stream (code 12) at io.c(276 +) [Receiver=3.1.1]
      But in general, it would be nice to execute scripts from within a perl launched by the usual windows command.com but with the environment of cygwin.

        One potential issue is that you probably have two Perl installations: Cygwin's Perl and ActiveState's ActivePerl. However, I'm suspecting that your issue has nothing to do with Perl. If you can't type the command at a command prompt (or in a Cygwin prompt) and get it to work properly, then calling the exact same command from Perl won't work.

        What has me a bit confused is that in your first post, you have:

        my $command = "c:\\cygwin64\\bin\\rsync.exe -ashv -e plink $user\@$host:/var/log/s +a/sar* .";

        Then in your last post, you have:

        C:\cygwin64\bin\rsync.exe -ashv -e plink --exclude=aide.log --exclude=aide_error.log weaverw@10.3.30.149:/var/log/aide

        The most recent version includes two '--exclude=' options in the command. The last option before those is a '-e' option. Looking at the documentation for rsync, the '-e' option does not have any suboptions. However, the '-F' option does allow for using an '--exclude' sub option, but there is no '-F' option in your command. Also, the documentation for plink does not show any '--exclude' options.

        Also, if I'm reading things correctly, the shorter command in your OP has a remote directory ($user\@$host:/var/log/s +a/sar*) and a local directory (.), but your second post shows an rsync command with only a remote directory (weaverw@10.3.30.149:/var/log/aide). According to the rsync documentation: "You use rsync in the same way you use rcp. You must specify a source and a destination, one of which may be remote." It looks like you're missing the local directory.

        Are you sure that you have your rsync command call correct?

        My suggestion would be to try to figure out the proper syntax of the rsync command that you're trying to run and then update your Perl script with the correct syntax for the command call.

Re: Running a cygwin command from within activestate
by Anonymous Monk on Mar 08, 2015 at 23:29 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1119265]
Approved by AppleFritter
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: (2)
As of 2024-04-26 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found