http://www.perlmonks.org?node_id=1018837


in reply to Router Backup.pl failing (operator error no doubt)

G'day rmagin,

Welcome to the monastery.

The message indicating a potential "runaway multi-line" is due to the chop() statement:

$ perl -ce 'chop ($status=\Q$snmpset $oid s $rtr.cfg\Q);' Substitution pattern not terminated at -e line 1.

\Q escape sequences are terminated with \E (not another \Q) and are applied to strings (i.e. they're not standalone operators):

$ perl -ce 'chop ($status="\Q$snmpset $oid s $rtr.cfg\E");' -e syntax OK

Take a look at quotemeta for a more complete description.

toolic may well be correct in suggesting you want `...` instead of \Q...\Q; however, you may also want to escape the ASCII non-"word" characters in the return value - something like this (untested) might do what you want:

$ perl -ce 'chop ($status = quotemeta(`$snmpset $oid s $rtr.cfg`));' -e syntax OK

-- Ken

Replies are listed 'Best First'.
Re^2: Router Backup.pl failing (operator error no doubt)
by Anonymous Monk on Feb 15, 2013 at 14:20 UTC

    Thank you Ken! that looks like it worked. Now just getting cp: cannot stat `/home/cisco/bkup/storage/LATEST/*': No such file or directory Can't open /home/cisco/bkup/RTR_LIST file at backup.pl line 29.

    This is no doubt because I have no file for it to run across so I can bang away at this...your explanation on the /Q and /E was right on the money and I tried your alt format and it runs clean on checks...thanks again for looking at it.

    After consideration I still think this is wrong way for me to go. I have stuff that won't download from snmp or mibs so I am going to search for a good perl/expect combo that I can use to telnet in get the prompts and send the downloads to a tftp server that i kick on and off

    Thank you both for the assist

    Rich