#perl - Tue 27 Mar 2007 between 03:36 and 03:44



PaladinWoosta: it's looking for a file to run called "grep email@address.com /var/log/maillog" which I'm guessing doesn't exist..
Woostaahhh ..
so the remote server is taking the third argument as a single argument .. interesting
PaladinWoosta: no.. the local one is.. shh is taking that as 1 arg, which it is, and trying to run it on the remote server..
Woostayeah, I wouldn't have thought exec was in charge at that stage :-D
PaladinWoosta: on the command line, does ssh host "grep foo bar" work?
WoostaI thought the 'command' arg to ssh could be a single arg
PaladinWoosta: IIRC, you need ssh host grep foo bar
WoostaIIRC it does
actionWoosta tests
Woostatests
Christian_ISmoin
WoostaIt does
ssh al "grep foobar@example.com /var/log/maillog"
^^ Succeeds
jonsmith1982``
Woostaahh
ssh al "grep\ foobar@example.com\ /var/log/maillog"
^^ fails
PaladinWoosta: ya.. it's because of the shell.. try as 3 args in perl
WoostaI need to quotemeta $needle and $haystack .. not the whole ssh command
jonsmith1982maybe its because @ needs escaping
Randalwhy do you \ the space between the args/
that's really wrong
WoostaRandal: trying to work out why the original code wasn't working
Is working now
exec( '/usr/bin/ssh', $_->hostname, join(' ', "grep", quotemeta $needle, quotemeta $haystack) );
^^ that works
quotemeta("grep $needle $haystack") was what I used to have
which is the equiv of the backslashed spaces
Randalmap quotemeta, @args;
PaladinWoosta: what about exec( '/usr/bin/ssh', $_->hostname,"grep", quotemeta $needle, quotemeta $haystack );
Woostayeah, my code sucks right now, but I wanted to make sure it worked
Paladin .. I'll check
actionamnesiac maps Paladin and Randal
amnesiacmaps Paladin and Randal
Randalexec 'ssh', $_->hostname, map quotemeta, @args;
Woostayup, pal, that works
WHich means Randal's will also
Randalit's too bad ssh doesn't treat its args like sh
sh -c 'command $1 $2' "first arg" "second arg"
Woostayeah :-D

Page: 3 10 17 24 31 38 45 52 59 66 73 80 87 94 101 108 115 

IrcArchive