Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
ias_gc-dk
Contributor
Jump to solution

ifconfig output differs from manual execution to script execution

Hello

I run a script every day on our VSX platform clusters with extracts a number of metrics for reporting about usage for each of our customers.

I wanted to expand the script to get the interface-values to make sure our documentation are up to date, but when I include this command to the bash-script:

ifconfig | grep -A1 Ethernet | grep -v '\-\-' | paste -sd ' \n' | awk '{ print $1","$7","$9 }' | awk -v vsname=$VS_NAME -F '[,:]' '{ print vsname","$1","$3"/"$5 }' >> /var/tmp/$Ldate-cp_facts_vs_interfaces_output-$1.txt

I get a different output, than if I run the command manually. The output in the script match what the \ifconfig puts out.

Example output:

Running command manually on a vs:

vs-customer1,bond1.3237,10.50.237.240/255.255.255.0
vs-customer1,bond3.1349,47.29.2.60/255.255.255.248
vs-customer1,wrp384,200.83.4.25/255.255.255.0

Running command in script on a vs:

vs-customer1,bond1.3237,100.127.48.1/255.255.255.240
vs-customer1,bond3.1349,100.127.48.17/255.255.255.240
vs-customer1,wrp384,100.127.48.33/255.255.255.240

Do I need to set a parameter in the script for ifconfig to give me the correct output, like with using specific checkpoint commands in scripts: source /etc/profile.d/CP.sh; ?

0 Kudos
8 Replies
This widget could not be displayed.