1

After establishing an SSH connection I've tried the following command to move a file from one folder to another one and renaming it:

command='cp /test/trial test/attempt/trial_something'  
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(command)

and it worked. Now I've tried, without success, to modify the command in this way:

command_test='/test/trial'
command='cp command_test test/attempt/trial_something'  
print (command)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(command)

the result of the print is

cp command_test test/attempt/trial_something

so basically the string is not build as the one in first example.

1
  • instead of ssh, you can use os.system() Commented Jul 5, 2022 at 8:28

1 Answer 1

1

I think I've found a way:

command_test='/test/trial'
command='cp ' + command_test + ' test/attempt/trial_something'  
print (command)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(command)

this worked to me.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.