bash - SSH in Shell to populate array with system information from remote host -
ssh $remote '( df -k )' > $remote_space (( i=0; i<no_dest; i++ )) ssh $remote "( aux_free_space[i]=$( du -sk ${aux_dest[${i}]} | cut -f 1 ) )" done all work ok apart populating array aux_free_space[]; think du runs on local host.
- ssh $remote works fine
- aux_free_space initialised @ beginning
- aux_dest populated
ssh $remote df -k > $remote_space ((i = 0; < no_dest; i++)); aux_free_space[i]=$(ssh $remote du -sk ${aux_dest[i]} | cut -f 1) done the array assignment has pulled out local shell, du must done remotely. cut can done on either side, cut down on levels of quoting can locally. (if du returned lot of output might choose cut remotely cut down on network traffic.)
Comments
Post a Comment