Sponsored Content
Top Forums Shell Programming and Scripting Store output in variables instead of files Post 302954237 by sam@sam on Saturday 5th of September 2015 07:02:38 PM
Old 09-05-2015
Hi, I was working on this ...for long time & stuck at some point
Now I m passing 3 variables poihostname userpid and username
Code:
poihostname =dellsys.com
while read userpid username
                do 
                ssh -n $username@$poihostname pwdx $userpid | awk '{print $2}'>> currpids
                done < ss

ss is filename and output is generated in a file called currpids.
more currpids
dell/server/serevr
dell/server/apache
dell/server/weblogic
now my requirement is I want to store the output in a variable instead of storing output in a file(currpids)........I have created a code but I m getting output for only third value(dell 457) & im not getting the output for 1st & 2nd values from file ss , let me know If your require any more info
more ss
dell 123
dell 456
dell 457
I m passing 3 parameters in file ss, but not getting accurate results
my new code look like this
Code:
while read userpid username
                do 
             currpids_71=`ssh -n $username@$poihostname pwdx $userpid | awk '{print $2}'`
                done < ss


Last edited by sam@sam; 09-05-2015 at 08:52 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract numbers from a string and store in variables

Hi All, Is it possible in Unix shell script to extract numbers from a string containing ".", such as; 5.2.314 And store in variables so; var1 = 5 var2 = 2 var3 = 314 Thanks in advance for any help anyone can provide dave (6 Replies)
Discussion started by: davewg
6 Replies

2. UNIX for Dummies Questions & Answers

trouble using read to store values in variables from command output

I know there are caveats about using read in pipelines because read is treated by a subshell. I know this but I can't think of any way to accomplish this regardless, I'm still a rookie. I hope somebody will be able to interpret what it is that I'm trying to accomplish and correct me. ... (2 Replies)
Discussion started by: ProGrammar
2 Replies

3. UNIX for Dummies Questions & Answers

trying to store variables in an array

im looping through an array setting three variables each time (one of the variables gives me the position in the array and is incremented each loop) im trying to then set the variables to that position in the array without much luck. any ideas? anArray=`$VAR1+$VAR2+"("$pos")"` (1 Reply)
Discussion started by: magnia
1 Replies

4. Shell Programming and Scripting

store multiple variables in one go

Guys anyone know how i can store fields into multiple variables in one go? I'm wanting to grab the disk id's from format into disk1 and disk2 Below is what i want to work but i know it doesnt :- : | format | awk '/^(\ +)/ {print $2}' | read disk1 disk2 The below does work...but i don't... (5 Replies)
Discussion started by: lavascript
5 Replies

5. Shell Programming and Scripting

to read two files, search for patterns and store the output in third file

hello i have two files temp.txt and temp_unique.text the second file consists the unique fields from the temp.txt file the strings stored are in the following form 4,4 17,12 15,65 4,4 14,41 15,65 65,89 1254,1298i'm able to run the following script to get the total count of a... (3 Replies)
Discussion started by: vaibhavkorde
3 Replies

6. UNIX for Dummies Questions & Answers

Writing a loop to manipulate a script and store it in multiple output files

I have a script where the the 9th line looks like this: $filename=sprintf("250.1chr%d.ped", $N); I want to modify this script 1000 times, changing 250.1chr%d.ped to 250.2chr%d.ped, 250.3chr%.ped.......and so on all the way to 250.1000chr%d.ped and store each output in files called ... (4 Replies)
Discussion started by: evelibertine
4 Replies

7. Shell Programming and Scripting

need to store query output fields in variables edit them and update the same in tables.

Hi , I have a query like select err_qty,drop_qty,unbld_qty,orig_qty from usage_data; I need to store the values of these fetched fields in variables, Need to edit them and update the new values into the table. Can anyone please help me in writing this piece of code:( (1 Reply)
Discussion started by: Rajesh Putnala
1 Replies

8. Shell Programming and Scripting

saving all input name and store them as variables

Hi I want to write a script such that when executed, it will store all input as different variable, for eg ./store.sh name1 name2 name3 name4 will result in $1=name1 $2=name2 $3=name3 etc How do I do that? Thanks. (1 Reply)
Discussion started by: piynik
1 Replies

9. Shell Programming and Scripting

Can -v option in awk be used to store an array of variables?

I want to pass an array of variables to be inserted by awk in the 2nd column of a file. Empl No. Employee Age 1000000 22 1100000 24 1200000 26 Now, I want to pass an array having three different ages which need to replace the... (7 Replies)
Discussion started by: Nishi_Licious
7 Replies

10. UNIX for Dummies Questions & Answers

Read in Multiple log files and output selected variables and values to cvs file

I have several problems with my problems: I hope you can help me. 1) the If else statement I am getting an error message. My syntax must be incorrect because the entire statement is throwing an error. For example in filew.log if these items don't exist Memsize, SASFoundation and also if... (0 Replies)
Discussion started by: dellanicholson
0 Replies
Info::Layer3::Dell(3pm) 				User Contributed Perl Documentation				   Info::Layer3::Dell(3pm)

NAME
SNMP::Info::Layer3::Dell - SNMP Interface to Dell Power Connect Network Devices AUTHOR
Eric Miller SYNOPSIS
# Let SNMP::Info determine the correct subclass for you. my $dell = new SNMP::Info( AutoSpecify => 1, Debug => 1, DestHost => 'myswitch', Community => 'public', Version => 1 ) or die "Can't connect to DestHost. "; my $class = $dell->class(); print "SNMP::Info determined this device to fall under subclass : $class "; DESCRIPTION
Provides abstraction to the configuration information obtainable from an Dell Power Connect device through SNMP. D-Link and the IBM BladeCenter Gigabit Ethernet Switch Module also use this module based upon MIB support. For speed or debugging purposes you can call the subclass directly, but not after determining a more specific class using the method above. my $dell = new SNMP::Info::Layer3::Dell(...); Inherited Classes SNMP::Info::Layer3 Required MIBs Dell-Vendor-MIB RADLAN-Physicaldescription-MIB RADLAN-rlInterfaces RADLAN-HWENVIROMENT Inherited Classes' MIBs See classes listed above for their required MIBs. GLOBALS
These are methods that return scalar value from SNMP $dell->os_ver() ("productIdentificationVersion") $dell->dell_id_name() ("productIdentificationDisplayName") $dell->model() Returns model type. Returns numeric from ("productIdentificationDisplayName") if available, otherwise if returns description(). $dell->vendor() Returns 'dell', 'dlink', or 'ibm' based upon the IANA enterprise number in id(). Defaults to 'dlink'. $dell->os() Returns 'dell', 'dlink', or 'ibm' based upon the IANA enterprise number in id(). Defaults to 'dlink'. Overrides $dell->serial() Returns serial number. Returns ("rlPhdUnitGenParamSerialNum") if available, otherwise uses the Layer3 serial method. Globals imported from SNMP::Info::Layer3 See documentation in "GLOBALS" in SNMP::Info::Layer3 for details. TABLE METHODS
These are methods that return tables of information in the form of a reference to a hash. RADLAN Interface Table ("swIfTable") $dell->dell_duplex_admin() ("swIfDuplexAdminMode") $dell->dell_duplex() ("swIfDuplexOperMode") $dell->dell_tag_mode() ("swIfTaggedMode") $dell->dell_i_type() ("swIfType") $dell->dell_fc_admin() ("swIfFlowControlMode") $dell->dell_speed_admin() ("swIfSpeedAdminMode") $dell->dell_auto() ("swIfSpeedDuplexAutoNegotiation") $dell->dell_fc() ("swIfOperFlowControlMode") Overrides $dell->interfaces() Returns the map between SNMP Interface Identifier (iid) and physical port name. Uses name if available instead of description since descriptions are sometimes not unique. $dell->i_duplex_admin() Returns reference to hash of iid to current link administrative duplex setting. $dell->fw_mac() Returns reference to hash of forwarding table MAC Addresses. Some devices don't implement the "BRIDGE-MIB" forwarding table, so we use the "Q-BRIDGE-MIB" forwarding table. Fall back to the "BRIDGE-MIB" if "Q-BRIDGE-MIB" doesn't return anything. $dell->fw_port() Returns reference to hash of forwarding table entries port interface identifier (iid) Some devices don't implement the "BRIDGE-MIB" forwarding table, so we use the "Q-BRIDGE-MIB" forwarding table. Fall back to the "BRIDGE-MIB" if "Q-BRIDGE-MIB" doesn't return anything. Table Methods imported from SNMP::Info::Layer3 See documentation in "TABLE METHODS" in SNMP::Info::Layer3 for details. perl v5.12.4 2011-09-28 Info::Layer3::Dell(3pm)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy