linux - Bash returning a no such file when file exists -
i'm trying run grep command on log file grab url utilize functions. problem keeps giving me no such file or directory
error whenever seek run it. thought bizarre prefixed ls
command see if did exist , lo , behold indeed there. can tell me issue is, have feeling it's syntax issue i'm not aware of can't figure out.
#!/bin/bash in `seq 1 3` ; ssh user@member${i}.domain.com << eof cd /home/path/member${i}/logs ls #i've printed output of below test=$( grep -op "http:.*microwebapp/$" "messages.log" ) echo "test variable = ${test}" exit eof done
the output of ls
command below:
console.log messages.log status.log trace.log
so i'm confused what's going on, i've tried replacing "messages.log"
"./messages.log"
no avail.
edit: here's total output 1 iteration of loop:
grep: ./messages.log: no such file or directory pseudo-terminal not allocated because stdin not terminal. console.log messages.log status.log trace.log test variable =
i suppose it's little odd grep
command throws error before ls
command runs don't have explanation either
because of "plain" heredoc, these lines execute on local machine, before shell hands command ssh
test=$( grep -op "http:.*microwebapp/$" "messages.log" ) echo "test variable = ${test}"
try:
ssh user@member${i}.domain.com << eof cd /home/path/member${i}/logs ls #i've printed output of below test=\$( grep -op "http:.*microwebapp/$" "messages.log" ) #....^ echo "test variable = \$test" #.....................^ exit eof
by "plain" heredoc, mean terminating word unquoted. 1 can set single quotes around word, , single quotes whole heredoc:
ssh remote_host <<'end' #.................^...^ h=$(hostname) d=$(date) echo time @ $h $d end
you can't in code because rely on expanding local var $i
alter right directory.
linux bash
No comments:
Post a Comment