Sponsored Content
Full Discussion: SFTP error in UNIX
Top Forums Shell Programming and Scripting SFTP error in UNIX Post 302980241 by Jesshelle David on Thursday 25th of August 2016 12:13:32 PM
Old 08-25-2016
Code:
USERNAME="$1"
export USERNAME
REMOTE_SERVER="$2"
export REMOTE_SERVER
LOCAL_DIRECTORY="$3"
export LOCAL_DIRECTORY
REMOTE_DIRECTORY="$4"
export REMOTE_DIRECTORY
DIRECTION="$5"
export DIRECTION
LOCAL_FILENAME="$6"
export LOCAL_FILENAME
REMOTE_FILENAME="$7"
export REMOTE_FILENAME
LOGFILE_PATH="$8"
export LOGFILE_PATH
LOG_FILENAME="$9"
export LOG_FILENAME
BIN_PATH="$10"
export BIN_PATH
LOCAL_JOBNAME="$11"
export LOCAL_JOBNAME
REMOTE_JOBNAME="$12"
export REMOTE_JOBNAME

##Validating if all inputs were entered
echo "Entering the program `date`" 																				| tee -a $LOG_FILEPATH/$LOG_FILENAME
if [ $# -ne 12 ]
then
echo "One or more inputs to this program were not entered." 													| tee -a $LOG_FILEPATH/$LOG_FILENAME
echo "Please verify the Appworx module" 																		| tee -a $LOG_FILEPATH/$LOG_FILENAME
echo "Aborting the program on `date`"																			| tee -a $LOG_FILEPATH/$LOG_FILENAME
exit 1
else
echo "All inputs to this program have been entered" 															| tee -a $LOG_FILEPATH/$LOG_FILENAME
fi

echo "Connecting to the BLUE Mainframe with USER:$USERNAME" 													| tee -a $LOG_FILEPATH/$LOG_FILENAME
echo "Remote host is: $REMOTE_SERVER"                                                                           | tee -a $LOG_FILEPATH/$LOG_FILENAME
sftp $USERNAME@$REMOTE_SERVER -omode=ascii >> $LOG_FILEPATH/$LOG_FILENAME  2>&1                        	        
ls /+showall																									
ls /+ mode=text,recfm=fb,lrecl=80,space=trk.8.1,release															
##quote site file=jes
pwd																												
lcd $LOCAL_DIRECTORY
lpwd																											
$DIRECTION $LOCAL_FILENAME $REMOTE_FILENAME																		
ls $REMOTE_FILENAME																								
cd //$REMOTE_DIRECTORY																							
ls /+mode=text,jesjobwait																						
lcd $BIN_PATH																									
lpwd																											
$DIRECTION $LOCAL_JOBNAME $REMOTE_JOBNAME																		
ls $REMOTE_JOBNAME																								
get /+/error.log 																								
quit

echo "SFTP connection successfully exited"  																	| tee -a $LOG_FILEPATH/$LOG_FILENAME
echo "Checking the log file for errors"																			| tee -a $LOG_FILEPATH/$LOG_FILENAME

cd $LOG_FILEPATH
sftp_check=`grep -i "Aborting the program" $LOG_FILENAME | wc -l`
if [ "$sftp_check" -gt 0 ]
then
        echo '\n'
        echo "##################################"
        echo  ERROR: Please enter the input parameters correctly.
        echo  'SFTP to Blue Server failed'
        echo "##################################"
        echo `date`
        exit 1
fi

sftp_check=`grep -i "Couldn't stat remote file" $LOG_FILENAME | wc -l`
if [ "$sftp_check" -gt 0 ]
then
        echo '\n'
        echo "##################################"
        echo  ERROR: SFTP Transfer Not Completed
        echo  'SFTP to Blue Server failed'
        echo "##################################"
        echo `date`
        exit 1
fi

sftp_check=`grep -i "No such file or directory" $LOG_FILENAME | wc -l`
if [ "$sftp_check" -gt 0 ]
then
        echo '\n'
        echo "##################################"
        echo  ERROR: SFTP Transfer Not Completed
        echo  'SFTP to Blue Server failed'
        echo "##################################"
        echo `date`
        exit 1
fi

echo "Script Completed"
echo"Exiting the program on `date`"

 

10 More Discussions You Might Find Interesting

1. HP-UX

sftp from unix to NT

Hi, 1) I want help on SFTP,Some commands not working in SFTP,but working in FTP example: bin,ls -xt ,user. Any alternate methos for this 2) if I want download files from UNIX to NT,I am able to download,but file format not connverting according to UNIX format(in NT end of line \n,but in... (1 Reply)
Discussion started by: anthonykomma
1 Replies

2. Shell Programming and Scripting

Error copying files from Unix (Solaris10) to Windows Server 2003 using scp/sftp

Hi, I have generated a Public/Private Key Pair in Solaris Unix (source) server and deployed the Public key in Windows 2003(target) server .ssh directory of user profile. When i try to connect(ssh, scp, sftp) from Unix, i'm getting below error message. Sun_SSH_1.1, SSH protocols 1.5/2.0,... (0 Replies)
Discussion started by: ajaykumarb
0 Replies

3. Linux

SFTP on SCO Unix

Hi, I have a request to install sftp on the Sco Unix Server. Request you please let me know the process for the installation of SFTP on Sco Unix Server. Thanks & Regards Arun (2 Replies)
Discussion started by: Arun.Kakarla
2 Replies

4. Shell Programming and Scripting

SFTP from Unix to Windows

Hi all Not sure where I should be posting this so apologies if it's in the wrong section. I'm trying to set up a system where we can copy a file (get) from a Windows server to a Unix server using SFTP in an automated way. I've installed CoreFTP Server on the Windows server and can connect... (2 Replies)
Discussion started by: huskie69
2 Replies

5. Shell Programming and Scripting

sftp to UNIX host

Hi, I am writing a shell script that securely connects to an UNIX host and transfer file(abc.txt) from the local machine to the host. sftp user@host get abc.txt bye The code doesn't work.. It throws error at line 2: get :Unknown get command. How can I rectify this problem? (2 Replies)
Discussion started by: Kishore_1
2 Replies

6. Shell Programming and Scripting

SFTP in UNIX

I need create a Shell script to do the SFTP process. How can i provide username and password in the script.I had the below code.But it ask for password.How can i add user name and password in this code echo "OK, starting now..." sftp -b /dev/fd/0 testwasds3l<<EOF cd /opt/isproj/VOM/Scripts... (2 Replies)
Discussion started by: morbid_angel
2 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. UNIX for Dummies Questions & Answers

Sftp from UNIX to mainframe

Hi, I have many scripts where i have used sftp for file transfer from unix box to unix box.. Now that we have to sftp files from unix to mainframe, i would like to know if that is possible. I just tried in the same way i did from unix to unix, but i got the error as connection refused. Are... (2 Replies)
Discussion started by: dnat
2 Replies

9. UNIX for Dummies Questions & Answers

SFTP error between UNIX to iSeries (Write Failed Broken Pipe)

Hi, I am iseries resource and having Issue in one of the sFTP failures between one of my job (Unix --> iSeries). The response to sending machine (Unix) is "Write Failed Broken Pipe". Appreciate any help Available on why this Issue happens, how can we replicate the same, what fixes can... (1 Reply)
Discussion started by: hamelchauhan
1 Replies

10. Shell Programming and Scripting

Needed SFTP script from windows to UNIX server and from UNIX to windows server(reverse SFTP)

hi guys, i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not and again i have to reverse sftp the files from unix to windows server..... regards, Vasa Saikumar. (13 Replies)
Discussion started by: hemanthsaikumar
13 Replies
Net::SFTP::Foreign::Compat(3pm) 			User Contributed Perl Documentation			   Net::SFTP::Foreign::Compat(3pm)

NAME
Net::SFTP::Foreign::Compat - Adaptor for Net::SFTP compatibility SYNOPSIS
use Net::SFTP::Foreign::Compat; my $sftp = Net::SFTP::Foreign::Compat->new($host); $sftp->get("foo", "bar"); $sftp->put("bar", "baz"); use Net::SFTP::Foreign::Compat ':supplant'; my $sftp = Net::SFTP->new($host); DESCRIPTION
This package is a wrapper around Net::SFTP::Foreign that provides an API (mostly) compatible with that of Net::SFTP. Methods on this package are identical to those in Net::SFTP except that Net::SFTP::Foreign::Attributes::Compat objects have to be used instead of Net::SFTP::Attributes. If the ":supplant" tag is used, this module installs also wrappers on the "Net::SFTP" and Net::SFTP::Attributes packages so no other parts of the program have to modified in order to move from Net::SFTP to Net::SFTP::Foreign. Setting defaults The hash %Net::SFTP::Foreign::DEFAULTS can be used to set default values for Net::SFTP::Foreign methods called under the hood and otherwise not accesible through the Net::SFTP API. The entries currently supported are: new => @opts extra options passed to Net::SFTP::Foreign constructor. get => @opts extra options passed to Net::SFTP::Foreign::get method. put => @opts extra options passed to Net::SFTP::Foreign::put method. ls => @opts extra options passed to Net::SFTP::Foreign::ls method. COPYRIGHT
Copyright (c) 2006-2008, 2011 Salvador Fandin~o All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-05-04 Net::SFTP::Foreign::Compat(3pm)
All times are GMT -4. The time now is 08:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy