I am trying to change the linux directory by using in SSH Command “cd /abcd/efgh” but it is not working, it always showing a root /home/ssss, Please guide me how to change directory

I am trying to change the linux directory by using in SSH Command
“cd /abcd/efgh”
but it is not working, it always showing a root
/home/ssss,
Please guide me how to change directory.

(am using uipath ssh connect command activity under ssh connect scope)

1 Like

There is no issue with path , path is alright and the same command working on Linux or putty session , here its not working in ui path custom activity ssh connect to server

2 Likes

Hi guys , do u have answer please , need your support.

@Khandaker_Rahaman

Why don’t you use putty instead ?

According to the developer, the commands aren’t preserved from one to the next. I had the same idea:
one command to “CD to dir”
next command to “run blah in that new dir”

But after the first command, the dir changes back to default because it’s like each command seems like it’s own little session. This makes me sad - but seems to be the case.

OK - I’ve been experimenting here and I’ve actually got a solution for the “CD” issue.
When using the SSH tool, the commands execute as though each were its own SSH session. So if you run a command like “cd /etc” and then use another ssh Run Command activity in sequence, the next command will NOT run in the context of /etc but starts out with the default shell directory.
Again, this is actually the expected behavior for the way this library was built.

Here’s your workaround. Through the magic of Unix’s ability to run chained commands, you can string together your work in a single sequential line of commands where the “cd” command will be respected.

Here’s an example:

“pwd; cd /etc; pwd; cat /etc/hosts; cd /usr; pwd”

That’s a silly example, but if you run it you’ll find that the “pwd” does show the change in directory.

However, if I run a second activity it will have forgotten all my “cd” changes. I hope that helps! I’m still trying to sort out what works and doesn’t.

As a bonus tip, you can also string together commands with a couple of joiners:

; - runs in sequence
& - runs commands in a row, but all in background so the results may not come back in the order you expect.
&& - runs commands in sequence, but only if the preceding command finished successfully