Sponsored Content
Full Discussion: SFTP Shell script
Top Forums Shell Programming and Scripting SFTP Shell script Post 302609995 by jim mcnamara on Tuesday 20th of March 2012 05:08:03 PM
Old 03-20-2012
1. yes.
2. Not like what you would want. Try the ls command that sftp offers

Code:
sftp $SFTP_USER@$SERVER <<EOF | grep -q 'No such file'
cd $SFTP_RDIR
ls $SFTP_RFILE
bye 
EOF
if [ $? -eq 1 ] ; then
  echo 'no such remote file'
else
sftp $SFTP_USER@$SERVER <<EOF 
cd $SFTP_RDIR
get $SFTP_RFILE
bye 
EOF
 
fi

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

f-secure sftp in shell script

Hi, I am trying to use sftp in a ksh - Shell script, but not even a simple script like this returns not output: sftp username@remotehost <<END ls END If I do something like this: sftp username@remotehost <<END | tee logfile ls END I get this error message: Warning: tcgetattr... (1 Reply)
Discussion started by: friand
1 Replies

2. Shell Programming and Scripting

SFTP shell script help

HI I need to write script to transefer files from windows server to UNIX and visa versa.... can any one enroute to the solution ........? I am new to SFTP .. would requst you provide some helpful informaion, Basics of SFTP also appreciated Thanks in Advance. Madan (1 Reply)
Discussion started by: madankumar
1 Replies

3. Shell Programming and Scripting

Reg sftp in shell script

Hi, I want to retrieve files from an sftp site and place it a directory in unix server. When I try to connect, it is asking password even if i hardcode it in the script.I want to automate the script. Could anyone tell me how to avoid password prompt. #!/bin/sh # sample automatic ftp script... (3 Replies)
Discussion started by: vidhya_vec
3 Replies

4. Shell Programming and Scripting

SFTP connection using shell script

Hi , I am able to manually connect to remote system usning "sftp" protocol. But when I using the below command in the script but I am not able to connect. `sftp TEST01@120.34.3.4` And the connection should not be closed after login. Please help to solve this. Thanks Satya (2 Replies)
Discussion started by: Satyak
2 Replies

5. Shell Programming and Scripting

shell script to get sftp files

did anyone knows a script to get a latest file in a folder,,i try to get the newest file at a folder via sftp and i want to make a crontab to do this once a day,,can someone give me the script to get the latest file?? (5 Replies)
Discussion started by: Cellscript
5 Replies

6. Shell Programming and Scripting

SFTP to server through Shell Script

I am sftp-ing to a server through a shell script from my local machine. sftp user@host put out.txt bye On executing the script, it prompts to enter the password, and after giving the password it successfully connects to the host.But the problem is that the remaining statements after the... (1 Reply)
Discussion started by: Kishore_1
1 Replies

7. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

8. Shell Programming and Scripting

Execute shell script within sftp session

Hi all , can any one tell me how to run a script within a sftp session. let me tell u in bit clear way : After I connected to sftp location , cd ing to some directory then I need to execute a one script. Please tell me if u have any idea on this . Looking forward to your reply guys... (1 Reply)
Discussion started by: sravan008
1 Replies

9. Shell Programming and Scripting

Help With SFTP using shell script

Hi All, Scenario : How to securely FTP the text file from a particular location(in unix system) to the windows ftp server (my PL is suggesting to use SCP command to accomplish this). Detailed description: I have created a Oracle job and scheduled it in dbms_scheduler. The job will invoke... (3 Replies)
Discussion started by: Sachi Vasishta
3 Replies

10. Shell Programming and Scripting

SFTP password through shell script.

Hi All, I would be happy, if someone help me on this that I have only SFTP ID and Password to transfer some log files from webserver boxes to SFTP server Anyone help me that how to pass the password parameter throough the shell scripts, since i don't have ssh login access on the SFTP... (2 Replies)
Discussion started by: l_gshankar24
2 Replies
SFTP-SERVER(8)						    BSD System Manager's Manual 					    SFTP-SERVER(8)

NAME
sftp-server -- SFTP server subsystem SYNOPSIS
sftp-server [-ehR] [-f log_facility] [-l log_level] [-u umask] DESCRIPTION
sftp-server is a program that speaks the server side of SFTP protocol to stdout and expects client requests from stdin. sftp-server is not intended to be called directly, but from sshd(8) using the Subsystem option. Command-line flags to sftp-server should be specified in the Subsystem declaration. See sshd_config(5) for more information. Valid options are: -e Causes sftp-server to print logging information to stderr instead of syslog for debugging. -f log_facility Specifies the facility code that is used when logging messages from sftp-server. The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The default is AUTH. -h Displays sftp-server usage information. -l log_level Specifies which messages will be logged by sftp-server. The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. INFO and VERBOSE log transactions that sftp-server performs on behalf of the client. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of debugging output. The default is ERROR. -R Places this instance of sftp-server into a read-only mode. Attempts to open files for writing, as well as other operations that change the state of the filesystem, will be denied. -u umask Sets an explicit umask(2) to be applied to newly-created files and directories, instead of the user's default mask. For logging to work, sftp-server must be able to access /dev/log. Use of sftp-server in a chroot configuration therefore requires that syslogd(8) establish a logging socket inside the chroot directory. SEE ALSO
sftp(1), ssh(1), sshd_config(5), sshd(8) T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-filexfer-00.txt, January 2001, work in progress material. HISTORY
sftp-server first appeared in OpenBSD 2.8. AUTHORS
Markus Friedl <markus@openbsd.org> BSD
January 9, 2010 BSD
All times are GMT -4. The time now is 05:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy