Hello all friends , i'm biginner in scripting , i just wanted to send i folder to a distant machine ising scp , without writing the password of the distant machine in terminal .For that , i found a script which is :

#!/usr/bin/expect -f
 
# effectue le transfert par SCP (sur SSH)
set timeout 3600
 
set localfile [lindex $argv 0]
set distfile [lindex $argv 1]
set servername [lindex $argv 2]
set password [lindex $argv 3]
 
spawn scp -r $localfile $servername:$distfile
expect "password:"
send -- "$password\r"
expect "100%"
exit 0

that receive arguments , this works nice ,send the folder ,without asking password (i passed it as argument from a python code), but i can't found all the files that was inside the folder in local machine in the new folder on the distant one .Maybe , the connexion ends when there 100% or maybe the connexion ends before that the copy is finished !!! and when i execute the comand :

scp -r /home/user/Bureau/SaveProg/ distuser@10.100.8.22:/home/distuser/Bureau/

it send the folder and it under-folders as well and all files .. Can some one have ideas please .

Hello , It's solved , the problem was : the script was created for sending a file , but in the case of a folder , with the options of scp :

-r -c blowfish

, it stops evrytime it finds "100%" , in the line :

expect "100%"

, and this don't let the other files to be sent .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.