bash - Waiting for input from script that is running remotely via ssh -
there script i'm running can not install on remote machine.
clear && printf '\e[3j' read -p "please enter device: " pattern read -p "enter date: (yyyy-mm-dd): " date pfix=$(cat /dev/urandom | tr -dc 'a-za-z0-9' | fold -w 5 | head -n 1) mkdir /home/user/logcollectres/"${pfix}" ssh xxx.xxx.xxx.xxx 'bash -s' < /usr/local/bin/searchadvanced.sh ${pattern} ${date} ${pfix}
in script, able use read.
ls -g *"${pattern}"* read -p "select 1 of these? [y/n] " "found";
i've tried adding -n on read -t -t option on ssh. can see script presents information seen once script starts, can't use read on local machine.
edit: lets server b stores syslogs 5k computers. file names given using internal ip of device , date @ end.
/var/log/remotes/192.168.1.500201505050736.gz /var/log/remotes/192.168.1.500201505050936.gz /var/log/remotes/192.168.1.500201505051136.gz /var/log/remotes/192.168.1.600201505050836.gz /var/log/remotes/192.168.1.600201505051036.gz /var/log/remotes/192.168.1.600201505051236.gz
i'd able select ip address main script, list files matching ip address, , select want scp local machine.
after speaking coworkers found answer running 2 scripts: first pulls ls -g result , directs answer variable on local machine. print output read option of selecting on of files. 2nd script take answer , scp file remote machine
in main script
ssh xxx.xxx.xxx.xxx 'bash -s' < /usr/local/bin/searchadvanced.sh ${pattern} ${date} > ${result}
then follow up
printf "${result}" read -p "select file: "
Comments
Post a Comment