LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Perl help (http://www.linuxquestions.org/questions/linux-software-2/perl-help-851462/)

kaoticsnow 12-20-2010 06:40 PM

Perl help
 
I'm having a bit of trouble with a perl script, I'm getting command not found errors when trying to define variables:

Code:

#!/usr/bin/perl
# Set behaviour
$workingdir="/home/cisco/bkup";
$snmprw="RW_STRING";
$ipaddress="172.16.1.5";
$days="30";


$rtrlist="$workingdir/RTR_LIST";
$storage="$workingdir/storage";
$latest="$storage/LATEST";
$prev="$storage/PREV";

I get the following errors when exicuting:

Code:

./backup.pl: line 9: =/home/cisco/bkup: No such file or directory
./backup.pl: line 10: =RW_STRING: command not found
./backup.pl: line 11: =172.16.1.5: command not found
./backup.pl: line 12: =30: command not found
./backup.pl: line 15: =/RTR_LIST: No such file or directory
./backup.pl: line 16: =/storage: No such file or directory
./backup.pl: line 17: =/LATEST: No such file or directory
./backup.pl: line 18: =/PREV: No such file or directory

I'm also getting errors about the working directory not existing, but it does:

Code:

[mon01 bkup]# pwd
/home/cisco/bkup

Ideas?

AlucardZero 12-20-2010 07:23 PM

How are you executing it? Does it behave different with "perl filename.pl" ?

kaoticsnow 12-20-2010 07:53 PM

That was one problem, Thanks! now I just need to figure out why its not able to connect to the device and pull the backups. but thats another issue I believe.

AlucardZero 12-20-2010 08:42 PM

Ok, so it sounds to me like you were trying to execute this perl script as a shell file. According to the shell, $workingdir would be empty, so the first non-comment line would be "=/home/cisco/bkup" which of course is not a valid commmand.

Assuming /usr/bin/perl exists, chmod'ing the file +x and running ./filename.pl should work. And so will "perl filename.pl" without having to set it executable.

kaoticsnow 12-20-2010 08:45 PM

I already chmod'ed the file +x but it made no difference, theres no problem simply executing it with the Perl command but I'm probably going to ditch the script anyway, as I can not get it to actually pull down the configs from my cisco devices.


All times are GMT -5. The time now is 02:36 AM.