I'm trying to login into multiple servers and execute the following command:
arp -an|grep lanx>lanx
I'm using this method:
ssh admin@10.x.x.x arp\ -an|grep\ lanx >lanx
but it is not working its giving me an error
ideally just put the commands in quotes like this:
ssh admin@10.x.x.x '/sbin/arp -an | grep lanx' > lanx
or
ssh admin@10.x.x.x '/sbin/arp -an' | grep lanx > lanx
The other problem might be the user admin on your machine does not have arp in PATH (is he root? arp is usually in /sbin/ and /sbin/ is usually not in PATH of a regular user.
put in subshell. something like this will make things more clear:
(ssh xxxx arp -an) | grep lanx > /tmp/lanx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.