SSH library and Execute command

381 views
Skip to first unread message

Varga Zsuzsa

unread,
Nov 19, 2021, 6:07:58 AM11/19/21
to robotframework-users
Hi,

I would like to delete a file on a remote server.
Copying (Put File) is fine.

 It does not delete the file the way I tried:

Open Connection    ${HOST}    port= ${PORT}  
Login With Public Key      ${LOGINNAME}    ${PrivateKeyFile}     # allow_agent=True
Execute Command    rm /transit/${File}

Thanks for any help
Zsuzsa

Hélio Guilherme

unread,
Nov 19, 2021, 9:14:16 AM11/19/21
to robotframework-users
There should be some error message of why it was not deleted. Permissions? Is the file really there? Maybe rm is using option -i. In this case try to add option -f.

You can try to use the option to have sudo powers.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/f80d7824-14b9-407e-ada8-c4e11a12f473n%40googlegroups.com.

Varga Zsuzsa

unread,
Nov 19, 2021, 10:01:35 AM11/19/21
to robotframework-users
The file is really there.
There is a robot file: put a file then try to delete it.


t.png

Hélio Guilherme

unread,
Nov 19, 2021, 11:22:08 AM11/19/21
to robotframework-users
It may be strange but try to run the following command before the `rm`:
Execute Command    chmod a+rw /transit/${File}

Next experiment is to (if your user can sudo):
Execute Command    rm -f /transit/${File} sudo=True

Another thing may be that the file is too big and it is not yet released to the file system.

Varga Zsuzsa

unread,
Nov 30, 2021, 7:43:10 AM11/30/21
to robotframework-users
Thanks for your answer.

All of  Execute commands do not work.
Seems 'Execute command' does not have permission to run a linux command


Hélio Guilherme

unread,
Nov 30, 2021, 12:02:33 PM11/30/21
to robotframework-users
Did you try the chmod before deleting?
You should debug by executing ls -l /transit/${File}

Varga Zsuzsa

unread,
Dec 2, 2021, 10:05:19 AM12/2/21
to robotframework-users
Yes, I tried chmod.
That is what I tried and it worked:
Put File    test.txt    /transit    mode=0755

All of the execute commands don't work.
Messages in the Log:
Command exited with return code 1.
This service allows sftp connections only.

I used 'Login with public key' to connect.
Although that's the message:  his service allows sftp connections only.

Zsuzsa

Hélio Guilherme

unread,
Dec 2, 2021, 10:24:48 AM12/2/21
to robotframework-users
So that is the explanation, only the SFTP commands work.


Varga Zsuzsa

unread,
Dec 2, 2021, 10:39:56 AM12/2/21
to robotframework-users
That means I can't delete the file?
Unforutnately, I do not know. :-(

Hélio Guilherme

unread,
Dec 2, 2021, 10:54:24 AM12/2/21
to robotframework-users
Maybe only using a normal client/terminal and enter the `rm` command as usual.
(just like normal FTP commands).

Varga Zsuzsa

unread,
Dec 2, 2021, 11:51:12 AM12/2/21
to robotframework-users
Yes, the normal mode is ok.
After one testing process  the task of the test would have been to delete the old file and create a new one, which would start another process.

Then it will be different. :-)

Thanks for your answers.
Reply all
Reply to author
Forward
0 new messages