Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-23-2016, 01:07 PM
rleon rleon is offline
Registered User
 
Join Date: Jan 2008
Posts: 116
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')
thanks
Reply With Quote
  #2  
Old 08-23-2016, 01:55 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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
Reply With Quote
  #3  
Old 08-25-2016, 01:18 PM
rleon rleon is offline
Registered User
 
Join Date: Jan 2008
Posts: 116
Hi Brenda

lol sorry I wasnt clear

Code:
crt.Screen.Send("scp -p -r -oStrictHostKeyChecking=no ssh_client.tar root@" + host + ":/root" + '\r')
I tried what you suggested but I get an error now.

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
Reply With Quote
  #4  
Old 08-25-2016, 02:02 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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
Reply With Quote
  #5  
Old 08-25-2016, 02:19 PM
rleon rleon is offline
Registered User
 
Join Date: Jan 2008
Posts: 116
hmmm I checked that ..

No extra characters.
Reply With Quote
  #6  
Old 08-25-2016, 03:03 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,099
Quote:
Originally Posted by rleon View Post
hmmm I checked that ..

No extra characters.
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]"))
The for-loop in python doesn't strip all end-of-line chars for you, so you have to be aware to remove them from variables so that you can use them in a command line. If the host variable has an LF or a CR in it, it will surely affect the way any command that you craft using the host variable.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 04:48 PM.