0

I'm triyng to make a bat file to ssh connect to a computer and run a command. However, this command is to open an UI, and it seems that, when Im running my bat script, the connection is closed after the execution. What is the best way to do this?

The commands I run mannualy for this to work:

ssh -XY user@hostname (digit my password) micromamba activate env open-ui.py 

I tried putting this on my bat file:

@echo off ssh -XYt user@hostname "micromamba activate env && open-ui.py" 

But it seems to close the terminal right after running the commands.

@echo off ssh -XYt user@hostname "micromamba activate env && open-ui.py" pause 

This seems to close the ssh connection before pausing, and

@echo off ssh -XYt user@hostname micromamba activate env open-ui.py pause 

This opens the ssh connection and then it does nothing else.

I dont mind typing my password mannualy. Can someone help?

7
  • Exactly what does open-ui.py do? Could you edit your question to include the script or the important parts of it? does it run another command in the background? Commented Jan 29 at 19:44
  • It is part of a bigger script to run the UIs, but I dont know if this is something relevant - the thing is, I want to run the commands I mentioned without it closing the ssh connection Commented Jan 29 at 19:47
  • You could try ssh -XYt user@hostname "micromamba activate env && open-ui.py && read" to stop ssh from closing the connection, this assumes that hostname is a linux server, for a windows host use pause instead of read Commented Jan 30 at 7:21
  • This still doesnt work. The connection still closes right after it execute the "micromamba activate env && open-ui.py && read". I tested it including a "mkdir test" before this commands and it does work - the directory is created, so the script is properly executing the commands. The only issue seems to be that it it closing right after the execution... Commented Jan 30 at 11:58
  • I suggest you read Best Way to Script Remote SSh Commands in Batch. Commented Feb 1 at 20:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.