Sponsored Content
Top Forums Shell Programming and Scripting Perl help - how to assign output of perl to variable Post 302774611 by whipuras on Saturday 2nd of March 2013 02:22:44 PM
Old 03-02-2013
Perl help - how to assign output of perl to variable

Hi, guys, i have a script i inherited from a coworker but i'm not perl savy. The script works but i would like it to work better. I want to run this command

./ciscomgrtest.pl -r "show version" -h hosts.router

and have the script goto each router in the hosts.router file and run the command "show version" on telnet.

Right now the script works but i have to put in the "show version" inside a variable inside the actual script like this.

Code:
#!/usr/local/bin/perl
#
#
use Net::Ping;
use Net::Telnet;
use Net::DNS::Resolver;
use Getopt::Std;
use lib '/home/sadmin';
use BER;
use SNMP_Session;


$COMMAND = 'show version';

How can i get that -r switch to put the "show version" from the command line into the variable when run? BTW the -r is arbitray, any switch would work.

hope this makes sense. thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to assign an output to a variable

Hi, I am giving a grep command, and i am getting the output. i want to store it in a variable for eg a = grep '12345' /dir/1/2/log.txt ( the output is number) b= grep 'basic' /dir/1/2/log1.txt (in this case the output is character) so how to assign the output of grep to a variable ... (1 Reply)
Discussion started by: vasikaran
1 Replies

2. Shell Programming and Scripting

hot to assign output to a variable

I want to assign a comment to a veriable for example my program head -1 myfile I want to assıgn output to a variable (1 Reply)
Discussion started by: walnut
1 Replies

3. Shell Programming and Scripting

Saving output from awk into a perl variable

How would I pass awk output to a perl variable? For example, I want to save the value in the 4th column into the variable called test. My best guess is something as follow, but I am sure this isn't correct. $test = system("awk '/NUMBER/{print \$4}' $_"); (8 Replies)
Discussion started by: userix
8 Replies

4. Shell Programming and Scripting

Piping and assigning output to a variable in Perl

Hi All, I am trying to convert the below Csh code into Perl. But i have the following error. Can any expert help ? Error: ls: *tac: No such file or directory Csh set $ST_file = `ls -rt *$testid*st*|tail -1`; Perl my $ST_file = `ls -rt *$testid*st*|tail -1`; (10 Replies)
Discussion started by: Raynon
10 Replies

5. Shell Programming and Scripting

how to assign the output of the interective script to the variable

Hi, I work in ksh88. I have an interective script which prompts the user for the input and returns numeric value depending on the input provided. I need to call this script inside another script and then assign the resulting output the the variable. The call like that A=`my script` obviously... (6 Replies)
Discussion started by: aoussenko
6 Replies

6. Shell Programming and Scripting

Perl:Read single value from text file and assign to variable

Hello All, A part of my very basic perl code requires me to read a single value from a text file. The file output is the following: Reading image ... done IMAGEREGION=0x0x0-256x162x256 VOXELDIMENSION=0.9375000000x1.2000000477x0.9375000000 VOXELNUMBER=10527001... (7 Replies)
Discussion started by: ncl
7 Replies

7. Shell Programming and Scripting

Assign perl output to ksh shell variable

Hello, I am writing a ksh script on an AIX system. I need to get the date and time from a file into a variable. I found the following perl script from another post on this site and modified it slightly to output the format I need: perl -e '@d=localtime ((stat(shift)));... (4 Replies)
Discussion started by: swimp
4 Replies

8. Shell Programming and Scripting

Assign output to dynamic variable

Hi Folks, I am trying to assign a value from the command to a dynamic variable. But I am not getting the desired output.. I am sure something is wrong so i need experts advise. There will be multiple files like /var/tmp/server_1, /var/tmp/server_2, /var/tmp/server_3, having different server... (6 Replies)
Discussion started by: ganga.dharan
6 Replies

9. UNIX for Dummies Questions & Answers

How can i assign directory path to a variable in perl?

Hai how can I assign directory path to a variable in perl Thanks&Regards kiran (2 Replies)
Discussion started by: kiran425
2 Replies

10. UNIX for Advanced & Expert Users

How can i assign directory path to a variable in perl?

Hai how can I assign directory path to a variable in perl Thanks&Regards kiran (3 Replies)
Discussion started by: kiran425
3 Replies
TNAT64(1)						      General Commands Manual							 TNAT64(1)

NAME
tnat64 - Shell wrapper to simplify the use of the tnat64(8) library to transparently allow an application to connect to IPv4 hosts via NAT64 on IPv6-only systems when the application doesn't support IPv6 itself. SYNOPSIS
tnat64 [application [application's arguments]] or tnat64 [on|off] or tnat64 DESCRIPTION
tnat64 is a wrapper between the tnat64 library and the application what you would like to run through NAT64. OPTIONS
[application [application's arguments]] run the application as specified with the environment (LD_PRELOAD) set such that tnat64(8) will transparently forward all connec- tions to the NAT64 via IPv6 [on|off] this option adds or removes tnat64(8) from the LD_PRELOAD environment variable. When tnat64(8) is in this variable all executed applications are automatically NAT64-ed. If you want to use this function, you HAVE to source the shell script from yours, like this: "source /usr/bin/tnat64" or ". /usr/bin/tnat64" Example: ". tnat64 on" -- add the tnat64 lib to LD_PRELOAD ". tnat64 off" -- remove the tnat64 lib from LD_PRELOAD [show|sh] show the current value of the LD_PRELOAD variable <without any argument> create a new shell with LD_PRELOAD including tnat64(8). AUTHOR
This script was created by Tamas SZERB <toma@rulez.org> for the Debian package of tsocks. It (along with this manual page) have since been adapted into the main tsocks project and modified, and then modified to be used with tnat64. TNAT64 TNAT64(1)
All times are GMT -4. The time now is 03:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy