I don't think we can do that within sftp. Only basic commands like ls works.
But since you have sftp set up, you can make use of ssh to check the directory existence and then proceed with sftp
--ahamed
Last edited by ahamed101; 09-20-2011 at 09:17 AM..
There are many servers and their directory structer should be exactly the same. To check the directory path for all servers, I wrote a script.
#! /bin/ksh
ARRAY_DIRECTORIES="/c/dev/custom/bin"
ARRAY_DIRECTORIES="/c/dev/db/custom/src"
ARRAY_ENV="remoteName200"
ARRAY_ENV="remoteName201"... (2 Replies)
I have the below script to check whether directory is exist or not , now I sure the directory /abc NOT exist , but when run the script , it still pop the result is "the directory exist" , could suggest what is wrong ? thx
ll -d /abc > /dev/null 2>&1
if
then
echo "the directory exist !!"
... (7 Replies)
I have a script that is working:
#!/bin/bash
sftp user@domain.com <<EOF
cd somedir
mget *.csv
quit
EOF
but on a crontab I want to only pull newer files, so I want to do something like:
while read ls current dir local file != true do
mget that new file
but I'm not sure the syntax... (2 Replies)
Hi ALL.
Can anyone could help me.
Have you had a chance to experienced that when you list (ls) a directory from ordinary execution of command, you couldn't see the directory.
However, when you list it from the directory filename itself or even changing to directory (cd), it will show to you... (9 Replies)
HI folks,
can any one tell me how to check whether the file is existed in a directory or not .
let me tell you my requirement : if the file is existed i should display a one message or else i have to send a mail ..
i have the mail logic .. but I'm failed to check file existence .. please... (5 Replies)
Hii all,
i create the user
useradd -d /home/kk kk
passwd kk
when i tried to login to kk
i get a error user directory doesn't exist
then i tried
useradd kkk
passwd kkkwhen i tried to login to kkk
i get the same error user directory doesn't exist. (4 Replies)
I'm brand new to AIX and I looked up how to print this file and it was working but now I'm not able to do it all of a sudden. the file name is rom1.txt so this is what i wrote in the command line and I know I'm in the right directory. In bold is what I seem to be messing up with.
prod @ root... (3 Replies)
I have built a website and I can access and edit the website'files on server via the root user. The current file and directory structures are not changeable. Now I am hiring a webpage designer to help me re-design some pages, I am going to let the designer edit the files directly on the server. So... (5 Replies)
Discussion started by: uwo-g-xw
5 Replies
LEARN ABOUT DEBIAN
libssh2_sftp_open_ex
libssh2_sftp_open_ex(3) libssh2 manual libssh2_sftp_open_ex(3)NAME
libssh2_sftp_open - open filehandle for file on SFTP.
SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>
LIBSSH2_SFTP_HANDLE *
libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp, const char *filename,
unsigned int filename_len, unsigned long flags,
long mode, int open_type);
DESCRIPTION
sftp - SFTP instance as returned by libssh2_sftp_init(3)
filename - Remote file/directory resource to open
filename_len - Length of filename
flags - Any reasonable combination of the LIBSSH2_FXF_* constants:
LIBSSH2_FXF_READ
Open the file for reading.
LIBSSH2_FXF_WRITE
Open the file for writing. If both this and LIBSSH2_FXF_READ are specified, the file is opened for both reading and writing.
LIBSSH2_FXF_APPEND
Force all writes to append data at the end of the file.
LIBSSH2_FXF_CREAT,
If this flag is specified, then a new file will be created if one does not already exist (if LIBSSH2_FXF_TRUNC is specified,
the new file will be truncated to zero length if it previously exists)
LIBSSH2_FXF_TRUNC
Forces an existing file with the same name to be truncated to zero length when creating a file by specifying LIB-
SSH2_FXF_CREAT. LIBSSH2_FXF_CREAT MUST also be specified if this flag is used.
LIBSSH2_FXF_EXCL
Causes the request to fail if the named file already exists. LIBSSH2_FXF_CREAT MUST also be specified if this flag is used.
mode - POSIX file permissions to assign if the file is being newly created. See the LIBSSH2_SFTP_S_* convenience defines in <lib-
ssh2_sftp.h>
open_type - Either of LIBSSH2_SFTP_OPENFILE (to open a file) or LIBSSH2_SFTP_OPENDIR (to open a directory).
RETURN VALUE
A pointer to the newly created LIBSSH2_SFTP_HANDLE instance or NULL on failure.
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.
LIBSSH2_ERROR_EAGAIN - Marked for non-blocking I/O but the call would block.
SEE ALSO libssh2_sftp_close_handle(3)libssh2 0.15 1 Jun 2007 libssh2_sftp_open_ex(3)