Skip to main content
11 events
when toggle format what by license comment
Jul 23, 2021 at 9:35 comment added MayD @Kusalananda - yes and have already indented terminating EOF in column 1, so no whitespaces/tabs. Used << 'EOF', so it's doing ssh to remote hosts but not supporting any variable expansion on remote, so proceeding commands after doing ssh step, are not getting executed. Values of variables are evaluated as blank on terminal.
Jul 22, 2021 at 18:17 comment added Kusalananda @user15762223 The terminating EOF must be flush left with no indentation and no whitespace after it. If you use <<-'EOF' (with <<- in place of just <<), then tabs are allowed before the terminating EOF, but not spaces.
Jul 22, 2021 at 18:05 comment added MayD @Kusalananda - using <<'EOF' fails script and returns syntax error - unexpected end of file. As I see it, quoting EOF disables all my code below it. It also does not allows variable expansion on remote hosts as I read somewhere. Tried this also << 'EOF' but no luck. As I mentioned, I wrote a different script for some other project requirement to connect to remote hosts and do some actions, it worked fine using ssh and <<-EOF. I just had to use $(declare -p variable) that were to be used on remote hosts. Tried using declare in this case, but strangely it's not working.
Jul 22, 2021 at 17:44 comment added Kusalananda @user15762223 I don't quite see why the validations need to happen remotely though. That just complicates the code. In any case, as both I and the other person have noted, the issue is due to not quoting the here-document. You would do that by using <<'EOF' to start the here-document.
Jul 22, 2021 at 17:38 comment added MayD @Kusalananda - i have a lot of code which needs to execute on multiple remote hosts. Part of business requirement. Have achieved executing commands on remote hosts using <<-EOF in one of other scripts. Not sure why the hell this one has issues. Anyways script runs in a loop to cover all the remote hosts to grep keyword in their respective log directories. What I have posted is just the first line of code after ssh where it fails. What remains after this are too many validations to be done. This also rules out the solution to use ssh to get the data, then run the commands locally on that data.
Jul 22, 2021 at 14:50 history edited Kusalananda CC BY-SA 4.0
added 72 characters in body
Jul 22, 2021 at 14:48 comment added Kusalananda @Archemar There is no indication that the code in the question is a minimal working example. In fact, the text explicitly says "Below is the piece of code with problematic grep", which makes me assume that this is the actual code they are using (the inclusion of tee -a also would not be part of a minimal working example). In any case, there is no other code in the question so this is all I have to go on. If the user needs to save the output of the awk in a variable, it would be easy to put my pipeline in a command substitution.
Jul 22, 2021 at 14:03 comment added Archemar I think OP gave us a minimal working example. and reals OP's shell is more complex, echo ${GetValue} would be show as a residual token, while actual shell might use it.
Jul 22, 2021 at 13:40 history edited Kusalananda CC BY-SA 4.0
added 1 character in body
Jul 22, 2021 at 13:26 history edited Kusalananda CC BY-SA 4.0
added 1 character in body
Jul 22, 2021 at 13:16 history answered Kusalananda CC BY-SA 4.0