06-19-2013
See example #6 here: thegeekstuff.com/2010/10/expect-examples/
As someone else suggested in this same thread, make sure your manager and your client understand that this is poor practice and certainly NOT the best way to get things done.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have been trying to implement the following shell script --
sftp to remote server
get list of files in the directory
sftp get the most recent listed file
exit
This script will be scheduled to be executed everyday using CRON or CONTROL-M and the need is to have absolutely no human... (7 Replies)
Discussion started by: toobrown1
7 Replies
2. Shell Programming and Scripting
How to automate sftp with out using expect script?
My batch file has the password but it is not taking. Please see below.
I want to use this sftp connection in a loop for pushing new files in a directory one at a time. Hence I can not use an expect script.
bash-2.05$... (5 Replies)
Discussion started by: Tuxidow
5 Replies
3. Programming
Hi,
I have 1. lappy
2. server A
3. server B
Now, what i need is to run a command from lappy that will sftp a file from server A to server B.
Please guide me to achieve this.
-akash (1 Reply)
Discussion started by: akash.mahakode
1 Replies
4. Red Hat
Hello,
I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration.
#pwd... (8 Replies)
Discussion started by: bobby320
8 Replies
5. Shell Programming and Scripting
Hi,
I want to execute shell script with in sftp session for remote server.
like i have a shell script test.sh that is on local server.i want to execute that script on remote server
sftp user@192.168.56.10
sftp> test.sh ---execute for remote server not for local server.
sftp... (3 Replies)
Discussion started by: SAUD PASHA
3 Replies
6. UNIX for Dummies Questions & Answers
Hi, guys, I am trying to automate a sftp process using "expect" method (since the key authentication method is disabled in my company network, there is no helping it).
In order to try, I type in the command manually:
sftp @ > << EOF
>cd
>ls -l
>EOF
>Connecting to
@servername password:
... (3 Replies)
Discussion started by: warmboy610
3 Replies
7. HP-UX
I am trying to connect to remote server in hp-ux, using sftp command (using sftp username@ip and password ) able to connect to remote server but, in this case sftp prompt for password and user need to manually enter it.
I want sftp can read a password define in script or from file, so it can... (1 Reply)
Discussion started by: ketanraut
1 Replies
8. Solaris
Hi,
I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script.
Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies
9. Shell Programming and Scripting
Hi there,
I'm trying to run a script remotely on a server in a particular directory named after hostname which already exists, my login session gets killed as soon as I run the below command. Not sure what is wrong, is there a better way to do it ?
Note: I can also use nohup command to run... (14 Replies)
Discussion started by: mbak
14 Replies
LEARN ABOUT DEBIAN
libssh2_sftp_write
libssh2_sftp_write(3) libssh2 manual libssh2_sftp_write(3)
NAME
libssh2_sftp_write - write SFTP data
SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>
ssize_t libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *handle,
const char *buffer,
size_t count);
DESCRIPTION
libssh2_sftp_write(3) writes a block of data to the SFTP server. This method is modeled after the POSIX write() function and uses the same
calling semantics.
handle - SFTP file handle as returned by libssh2_sftp_open_ex(3).
buffer - points to the data to send off.
count - Number of bytes from 'buffer' to write. Note that it may not be possible to write all bytes as requested.
libssh2_sftp_handle(3) will use as much as possible of the buffer and put it into a single SFTP protocol packet. This means that to get
maximum performance when sending larger files, you should try to always pass in at least 32K of data to this function.
WRITE AHEAD
Starting in libssh2 version 1.2.8, the default behavior of libssh2 is to create several smaller outgoing packets for all data you pass to
this function and it will return a positive number as soon as the first packet is acknowledged from the server.
This has the effect that sometimes more data has been sent off but isn't acked yet when this function returns, and when this function is
subsequently called again to write more data, libssh2 will immediately figure out that the data is already received remotely.
In most normal situation this should not cause any problems, but it should be noted that if you've once called libssh2_sftp_write() with
data and it returns short, you MUST still assume that the rest of the data might've been cached so you need to make sure you don't alter
that data and think that the version you have in your next function invoke will be detected or used.
The reason for this funny behavior is that SFTP can only send 32K data in each packet and it gets all packets acked individually. This
means we cannot use a simple serial approach if we want to reach high performance even on high latency connections. And we want that.
RETURN VALUE
Actual number of bytes written or negative on failure.
If used in non-blocking mode, it returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is a negative num-
ber, it isn't really a failure per se.
If this function returns 0 (zero) it should not be considered an error, but simply that there was no error but yet no payload data got sent
to the other end.
ERRORS
LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed.
LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket.
LIBSSH2_ERROR_SOCKET_TIMEOUT -
LIBSSH2_ERROR_SFTP_PROTOCOL - An invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be
returned by the server.
SEE ALSO
libssh2_sftp_open_ex(3)
libssh2 0.15 1 Jun 2007 libssh2_sftp_write(3)