You are not logged in.
Pages: 1
Hi everyone!
I'm in a bit of a pickle here because I'm trying to use xfce4-terminal to spawn a standalone terminal that will ssh into a target computer, cd to a folder and then tail a log file there.
However the construction of the command to be executed does not seem to be fed correctly to the new terminal.
Following is an attempt at an "MWE"
#!/bin/bash
total_command="ssh $target_adress 'bash -s' <<< \"cd /homes/$USER/ && tail -f *.log[0-9]*\""
echo "Trying: $total_command"
xfce4-terminal --hold -e "$total_command"
When I execute the echoed total_command it works as expected. However the xfce4-terminal does not seem to properly ssh before trying to execute the commands. Giving the error "No such file or directory".
Anyone have any clues as to why this is not working?
Kind Regards,
Offline
Hello and welcome.
You're commands work here for me. I do notice though, that "$target_adress" is misspelled. Can you confirm you have that variable correct?
Also, which version of xfce4-terminal are you using?
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Hello and welcome.
You're commands work here for me. I do notice though, that "$target_adress" is misspelled. Can you confirm you have that variable correct?
Also, which version of xfce4-terminal are you using?
So you managed to ssh and subsequently cd then tail a file?
Yes the variable is misspelled at assignment too
xfce4-terminal 1.0.4 (Xfce 4.16)
Offline
With respect to:
However the xfce4-terminal does not seem to properly ssh before trying to execute the commands.
...yes. I was testing with these commands:
total_command="ssh localhost 'bash -s' <<< \"ls\""
xfce4-terminal --hold -e "$total_command"
However, re-reading your original post just now, I thought I would try to tail a log file, but that didn't work for me either, until I escaped all the spaces and ampersands:
total_command="ssh localhost 'bash -s' <<< \"cd\ /var/log\ \&\&\ tail\ -f\ pacman.log\""
I'm not exactly sure why this is needed - it seems to process the spaces and ampersands as something other than that.
Edit: it would process it all as one long command name. Interesting.
xfce4-terminal 1.1.1 (Xfce 4.18)
Last edited by ToZ (2023-12-11 14:18:50)
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
With respect to:
However the xfce4-terminal does not seem to properly ssh before trying to execute the commands.
...yes. I was testing with these commands:
total_command="ssh localhost 'bash -s' <<< \"ls\"" xfce4-terminal --hold -e "$total_command"
However, re-reading your original post just now, I thought I would try to tail a log file, but that didn't work for me either, until I escaped all the spaces and ampersands:
total_command="ssh localhost 'bash -s' <<< \"cd\ /var/log\ \&\&\ tail\ -f\ pacman.log\""
I'm not exactly sure why this is needed - it seems to process the spaces and ampersands as something other than that.
Edit: it would process it all as one long command name. Interesting.
xfce4-terminal 1.1.1 (Xfce 4.18)
Let me just say WOW!
Thank you for making such an excellent find!
I will now escape
Cheerio!
Offline
I have now tested it and it works as expected, I would never have figured out to escape the spaces and ampersands... What made you consider that?
Regards,
Offline
I have now tested it and it works as expected, I would never have figured out to escape the spaces and ampersands... What made you consider that?
Basically trial and error. Read up on "bash -s", looked at the error message in ~/.xsession-errors and realized it wasn't processing the string properly.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Regretful wrote:I have now tested it and it works as expected, I would never have figured out to escape the spaces and ampersands... What made you consider that?
Basically trial and error. Read up on "bash -s", looked at the error message in ~/.xsession-errors and realized it wasn't processing the string properly.
Ah, wouldn't have thought to look in ~/.xsession-errors. Lots of things to learn, still new to bash it seems!
Offline
Pages: 1
[ Generated in 0.009 seconds, 8 queries executed - Memory usage: 549.61 KiB (Peak: 566.89 KiB) ]