I have a script that I want to monitor its results and write them to a log file. I run the following:

gnome-terminal -x bash -c "script logfile.log; ssh user@IP"

But this command execute first the first command and after that the 2nd. Can I do them like in series without any input from me? to execute first the script command to write the logfile I want and after that the ssh without I need to do something else?

I tried the way it is and it doesn't do what I want.

1 Answer 1


Have you tried having script be the outer part

gnome-terminal -x script -c "ssh user@IP" logfile.log
  • and what if i want to use something like | tee logfile.log OR > logfile.log
    – user178591
    Jul 7, 2016 at 13:27
  • Well, you could still put the bash -c part there if you want and have script -c be part of what it executes Jul 7, 2016 at 13:28
  • thanks for the help. that worked perfect! Now, i try to run multiple tabs for multiple ssh and it doesn't work. I try: gnome-terminal --working-directory=$PATH --tab-with-profile=$IP1 -x script -c "ssh user1@IP1" $PATH_REPORT/IP1.log --tab-with-profile=$IP2 -x script -c "ssh user@IP2" $PATH_REPORT/IP2.log
    – user178591
    Jul 7, 2016 at 14:08
  • @Kostas Try quoting the entire command and using -e instead of -x like: gnome-terminal --tab-with-profile=$IP1 -e "script -c 'ssh user@$IP1' $PATH_REPORT/IP1.log" --tab-with-profile=$IP2 -e "... and if that doesn't work, it'd be better to ask this as a new question instead of using the comments further Jul 7, 2016 at 15:34
  • Actually it worked. Thanks for your help!!! +9000! :D
    – user178591
    Jul 7, 2016 at 15:42

You must log in to answer this question.