0

I am using a script which is basically identical to the first one in https://stackoverflow.com/a/4783182/7238575. It works perfectly when run in the terminal or using the option "Run in terminal" (when setting the preference to asking what to do when double clicking a script in Nautilus). However, when I just "Run" it (or when the preference is set to run) it does not work.

What is the difference and what is going on? How can I make the script work with the default "Run" (I would prefer to keep the preference to always use "Run" so that I can just double click to run the script without any dialogs.)


I tried to source bashrc by adding source ~/.bashrc to get the same environment but that made the script fail even from the terminal so I must have done something wrong. (I commented out the lines in bashrc that preven it from running in interactive mode).

Kvothe
  • 233
  • 1
  • 8
  • P.S. I asked at askubuntu but was adviced to ask here instead. – Kvothe Nov 19 '20 at 11:01
  • 1
    `interact` works only when Expect is running on a tty/pty. the "Run" does not allocate a pty i believe. so try changing `interact` to other Expect commands. e.g. if `interact` is in the end you can just `expect -timeout -1 eof`. – sexpect - Expect for Shells Nov 19 '20 at 11:27
  • Yes, use `expect eof`. Also, no reason to `eval spawn ...` there, just `spawn ...` – glenn jackman Nov 19 '20 at 14:56
  • @glenn, I replaced `interact` with `expect eof` except the last one with `expect -timeout -1 eof` and removed eval. Now the script doesn't work from terminal or from run. – Kvothe Nov 19 '20 at 15:10
  • What does "doesn't work" mean? – glenn jackman Nov 19 '20 at 16:02
  • @glenn, in this case it means it fails to log in to a vpn server. (Under run I don't really see any output to tell where it is going wrong. Before as it was under the terminal you could see it went through all the right steps, giving the correct responses to the queries.) – Kvothe Nov 19 '20 at 16:03
  • Sorry, I don't know what's going on. Clearly, revert that change to use `interact`. But you'll have to do some more research about how programs get launched with "run in terminal" – glenn jackman Nov 19 '20 at 16:08
  • only the *last* `interact` can be replaced with `expect eof`. it's not clear to me why `interact` is used in other places as in the answer you are referring to. – sexpect - Expect for Shells Nov 20 '20 at 01:50

0 Answers0