Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Router Backup.pl failing (operator error no doubt)

by kcott (Abbot)
on Feb 15, 2013 at 04:14 UTC ( #1018837=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Router Backup.pl failing (operator error no doubt)
Select or Download Code
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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2015-07-30 23:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls