Hi *,
I'm trying to connect to sftp server using password authentication in CL program. I've found, that I can do this:
My connection is successful, but now I'm trying to do some operations there.
The one of steps looks like:
printf "get /home/milbank/vpncfg.txt\nquit\n" | serverUserID@server
but in this place I'd like to do something like this (go to dir, create a list of files, get this list, quit):
printf "cd /home/myusr\nls > lista.txt\nget lista.txt\nquit\n" | serverUserID@server
Log of 'ls' operation shows:
sftp> ls > lista.txt
debug3: Sent message fd 4 T:7 I:4
debug3: Received stat reply T:101 I:4
debug1: Couldn't stat remote file: No such file or directory
Can't ls: "/home/myusr/>" not found
sftp> quit
I'm completely newbie in scripts area and don't want advices like "you can do it simplier using..." or "you can do it on another way". Copy-paste is the only way I understand in scripts world I'd like to connect on the way shown in the article, but I don't know, how to prepare printf statement to generate a file with a list of files in given directory, and then download this file.
Directrory /home/myusr/ on remote exists, authority ok, 'pwd' command gives the correct directory afer cd /home/myusr/.
I've tried to do this from terminal by call qp2term -> ssh serverUserID@server. Command ls > lista.txt gave me exactly what I wanted. But I can't do that using sftp client. Is it even possible? I completely don't understand "Couldn't stat remote file: No such file or directory" in this log. Is it some administrative task or it's simply not possible to ls to file with sftp client?
I'm trying to connect to sftp server using password authentication in CL program. I've found, that I can do this:
My connection is successful, but now I'm trying to do some operations there.
The one of steps looks like:
printf "get /home/milbank/vpncfg.txt\nquit\n" | serverUserID@server
but in this place I'd like to do something like this (go to dir, create a list of files, get this list, quit):
printf "cd /home/myusr\nls > lista.txt\nget lista.txt\nquit\n" | serverUserID@server
Log of 'ls' operation shows:
sftp> ls > lista.txt
debug3: Sent message fd 4 T:7 I:4
debug3: Received stat reply T:101 I:4
debug1: Couldn't stat remote file: No such file or directory
Can't ls: "/home/myusr/>" not found
sftp> quit
I'm completely newbie in scripts area and don't want advices like "you can do it simplier using..." or "you can do it on another way". Copy-paste is the only way I understand in scripts world I'd like to connect on the way shown in the article, but I don't know, how to prepare printf statement to generate a file with a list of files in given directory, and then download this file.
Directrory /home/myusr/ on remote exists, authority ok, 'pwd' command gives the correct directory afer cd /home/myusr/.
I've tried to do this from terminal by call qp2term -> ssh serverUserID@server. Command ls > lista.txt gave me exactly what I wanted. But I can't do that using sftp client. Is it even possible? I completely don't understand "Couldn't stat remote file: No such file or directory" in this log. Is it some administrative task or it's simply not possible to ls to file with sftp client?