#1
|
|||
|
|||
send scp command with path .
How do I send an scp command?
I cant seem to be able to figure out how to do the characters after the host. scp -p -r myfile root@host:/path/to/dir/ Code:
crt.Screen.Send("ssh -oStrictHostKeyChecking=no root@" + host + '\r') |
#2
|
|||
|
|||
Hi rleon,
Sorry to appear dense, but I don't understand what you don't understand. ![]() Also, your question is about scp, but then the example code is ssh? I assume "/path/to/dir/" is a literal string, you would just treat it as such: Code:
crt.Screen.Send("ssh -oStrictHostKeyChecking=no root@" + host + ":/DirA/DirB/DirC/etc" + '\r') or crt.Screen.Send("scp -p -r my file root@" + host + ":/DirA/DirB/DirC/etc" + '\r')
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Hi Brenda
lol sorry I wasnt clear Code:
crt.Screen.Send("scp -p -r -oStrictHostKeyChecking=no ssh_client.tar root@" + host + ":/root" + '\r') For some reason its putting an extra character in there. Code:
# scp -p -r -oStrictHostKeyChecking=no ssh_client.tar root@myhost [rleon:/home/rleon]# :/root -bash: :/root: No such file or directory |
#4
|
|||
|
|||
Hi rleon,
I would say then that the info read from the hosts file includes an extra end of line character that needs stripped! ![]()
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#5
|
|||
|
|||
hmmm I checked that ..
No extra characters. |
#6
|
||||
|
||||
The extra char(s) are there, you just won't be able to see them since they're non-printing.
This should demonstrate for you what's going on: Code:
with open('/Users/rleon/Documents/hosts.5') as hosts_: for host in hosts_: crt.Dialog.MessageBox(host.replace("\r", "[CR]").replace("\n", "[LF]")) --Jake
__________________
Jake Devenport VanDyke Software Technical Support YouTube Channel: https://www.youtube.com/vandykesoftware Email: support@vandyke.com Web: https://www.vandyke.com/support |
#7
|
|||
|
|||
It has an LF in the dialog box.
But I dont see any lines or characters returns. Code:
# cat -vet hosts 10.255.43.12$ 10.255.43.13$ 10.255.43.14$ 10.255.43.15$ |
#8
|
||||
|
||||
They're in there, rleon, otherwise there wouldn't be any lines in your file!
(your file would show up as a singular, long line) Lines in a text file are terminated with special characters to signal where the end of the line is (EOL = End Of Line). On UNIX-based systems, the EOL character is typically a \n (LF) character, which 'cat' displays as '$' (as described in the man page for 'cat'). Your output of 'cat -vet hosts' clearly shows '$' at the end of each line. I've already shown you one way to use 'replace()' to make the \n char visible in the dialog as [LF]. All you need to do is use that same replace() call to replace any LF or CR with an empty string (e.g. remove them), as in: host = host.replace("\n", "").replace("\r", "")--Jake
__________________
Jake Devenport VanDyke Software Technical Support YouTube Channel: https://www.youtube.com/vandykesoftware Email: support@vandyke.com Web: https://www.vandyke.com/support |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|