thanks, - I did not expect that $ can be problem - I expected ' {} or ()
Now I am facing another problems:
I use ssh in script to access various systems (solaris, hp-ux, linux...) if I want remote use ifconfig somewhere it works somewhere not.
I found that that may be the PATH problem or something with sourcing and variables - I am not familiar with it and I am a little bit confused, but anyway it is recommend to use /sbin/ifconfig (as you did)
OK but what if somewhere is ifconfig in another path ? Is possible to use classic ifconfig in script?
Second problem: Is possible to remote use bash script for loop on system which did not have bash ? Example is more than 1000 words:
#!/bin/bash
for hpux_server in `cat hpux_servers`
do
output=`ssh $hpux_server "for lan in \$(/usr/sbin/lanscan | grep lan | awk '{print \$5}'); do /usr/sbin/ifconfig \$lan; done" | grep -v 127.0.0.1 | grep 'inet'`
# ssh hpux_server "for lan in \$(/usr/sbin/lanscan | grep lan | awk '{print \$5}'); do /usr/sbin/ifconfig \$lan; done"
echo -e "${hpux_server}:\n=============\n${output}\n=============\n=============\n" >> final_hpux_list
done
The commented line in above code works if it is not in bash script
Third problem: Is good practice to set environment variables when I log on server via script (to avoid expecting input) ? Is it necessary for script to have set environment variables or is there any better solution ?
No, as far as I know, ifconfig's position and syntax varies accross different operating systems,
so I would suggest to use a custom code for your environment.
Could you post the exact error message or explain what you mean by "not working"?
I'm not sure about this one. Some ssh client implementations support the -t/-T switch to enable/disable pseudo-tty allocation,
I don't know if setting the above mentioned variables has some impact.