This question already has an answer here:
I got the task of logging into some 300 devices, execute the following commands and then copy the output into one file.
I can use SSH as a login method and I can give a predefined username and password.
Once we are in the device I need to log into expert mode and provide the predefined password.
$ expert >>> provide password $ lspci | egrep -i --color 'network|ethernet'
Copy the output to file
I prepared the following script:
#!/bin/bash username=XXXX passwd=XXX cd /tmp for host in `cat servers.txt`; do ssh $username@$host $passwd; expert echo "### $host ###" >> output.txt lspci | egrep -i --color 'network|ethernet' >> output.txt done
After prompting for the password, it gives me following:
Running commands is not allowed ./fibertest.sh: line 9: expert: command not found
It seems like it is not running the command on the remote, but on the local machine.