Sponsored Content
Top Forums UNIX for Dummies Questions & Answers ISSUE on SFTP fucntion ,parameter passing! Post 302364465 by bobprabhu on Friday 23rd of October 2009 06:49:57 AM
Old 10-23-2009
Bug ISSUE on SFTP fucntion ,parameter passing!

Hi Everyone!!

Hey i created a SFTP function to FTP the file from unix to Linux.

I need to FTP the 48 files from unix to linux.

Code:
IP=$1
Userid=$2
Prikeypath=$3
SrcPath=$4
DstPath=$5
Files=$6
BATCHFILE=sftp.batch.$$
LOGFILE=sftp.log.$$
#Compose batch file & pass as argument to the scipt.

if [ ${SrcPath} != "D" ]
then
echo "lcd $SrcPath" >> ${BATCHFILE}
fi

if [ $DstPath != "D" ]
then
echo "cd $DstPath" >> ${BATCHFILE}
fi

NoofFiles=`echo $Files | grep -c ,`
NoofFiles=`expr ${NoofFiles} + 1`

if [ $NoofFiles -gt 0 ]
then
while [ $NoofFiles -gt 0 ]
do
File=`echo $Files | cut -d"," -f${NoofFiles}`
echo "put $File" >> ${BATCHFILE}
NoofFiles=`expr $NoofFiles - 1`
done
fi

echo "bye" >> ${BATCHFILE}

if [ $Prikeypath != "D" ]
then
sftp -oIdentityFile=${Prikeypath} -oPubkeyAuthentication=yes -oPasswordAuthentication=no -b ${BATCHFILE} ${Userid}@${IP}
 > ${LOGFILE} >> ${LOGFILE} 2>&1
else
sftp -oPubkeyAuthentication=yes -oPasswordAuthentication=no -b ${BATCHFILE} ${Userid}@${IP} > ${LOGFILE} >> ${LOGFILE} 2
>&1
fi


if [ $? -ne 0 ]
then
echo "SFTP session failed. Please refer ${LOGFILE} for further details"
else
echo "SFTP session succeeded."
#rm -f ${LOGFILE}
#rm -f ${BATCHFILE}
fi

fi
}

This is the fucntion.

The issue is
Code:
dosftp <ipadresss)  <User_Name> <Private_Keypath> <Source_Path> <Destination_Path> Abc*.txt,Bcd*.eof,xyz*.eof,crw*.txt

If i excute the fucntion like this,from the source path it's FTP ing only the first 2 files(Abc*.txt,Bcd*.eof)
but i need to ftp all the files(Abc*.txt,Bcd*.eof,xyz*.eof,crw*.txt) ,How i can modify my function to SFTP the n number of parameters in a single execution.

Please advice.

Thanks in Advance.

Last edited by zaxxon; 10-23-2009 at 08:36 AM.. Reason: code tags!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

parameter passing

Hallo everyone, This is my problem below: /home/cerebrus/pax=>vat class2.sh ksh: vat: not found /home/cerebrus/pax=>cat class2.sh #!/bin/ksh set -x bdf|grep appsdev|awk '{ print $5 }'> class3 dd={cat class3} echo $dd /home/cerebrus/pax=> /home/cerebrus/pax=>./class2.sh + bdf +... (8 Replies)
Discussion started by: kekanap
8 Replies

2. Programming

Passing parameter to makefile?

Hi, How to pass parameter to makefile? Please let me know if any one knows and also please put an example of makefile with this feature. thanks, Manju. (3 Replies)
Discussion started by: manju_p
3 Replies

3. Shell Programming and Scripting

wrong parameter passing!

Hi all I have a script which will take input as filename and passes it to a java program. It is as follows -------------------------------- FILENAME=$1 echo $FILENAME ${JAVA_HOME}/bin/java -cp DateProvider $FILENAME ------------------------------------------------- when I execute the same... (2 Replies)
Discussion started by: malle
2 Replies

4. Programming

Sleep or Dealy fucntion Issue

I am doing some programming using C on UNIX. The thing is, I have been working in both UNIX and Windows for practicing. I created a Delay fucntion over Windows using DevC++ as a compiler, when I tried over the console, it worked as I expected, I mean it was creating a delay (of one second for... (10 Replies)
Discussion started by: josejesus3340
10 Replies

5. Shell Programming and Scripting

Parameter Passing problem

Hi All, I developed a KSH script which will accept two parameters as input. These two parameters are some directories paths. In the script i am validating the number of paramaters it received as below #-------------------------------------- # Check Command line arguments... (8 Replies)
Discussion started by: Raamc
8 Replies

6. Shell Programming and Scripting

Passing parameter in quotes

Hi, PW='/as sysdba'; export PW in other module I call sqlplus ${PW} (this line I unable to change!) How I can define PW so that sqlplus calls PW in quotes i.e sqlplus '/as sysdba' I tried like this PW="'/as sysdba'"; export PW - no luck Thanks in advance (2 Replies)
Discussion started by: zam
2 Replies

7. Shell Programming and Scripting

Positional parameter passing

Hi All, When passing parameters to a sheel script, the parameters are referenced by their positions such as $1 for first parameter, $2 for second parameter. these positional values can only have values ranging from $0-$9 (0,1,2,3...9). I have a shell script meant to accept 20 parameters. for... (3 Replies)
Discussion started by: ogologoma
3 Replies

8. Shell Programming and Scripting

Issue in passing a parameter value from one script to another

Hi Experts, I am passing current month & day (i.e. 'Jul 21') from script aaa.ksh to zzz.ksh. The value 'Mon DD' is being used in zzz.ksh. Problem: If I pass 'Mon DD' value manually to zzz.ksh i.e. /test/zzz.ksh 'Jul 21' it works fine. However, if I pass value from aaa.ksh, it does... (2 Replies)
Discussion started by: dipeshvshah
2 Replies

9. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

10. Shell Programming and Scripting

Passing parameter more than 9

Hi, I've written a script where eleven parameter to be passed from command line which is inserting into an oracle table, it is working but the tenth and 11th parameter are not accepting as given it is referring to 1st parameter. HERE IS THE SCRIPT #!/bin/ksh #set -o echo $*... (4 Replies)
Discussion started by: sankar
4 Replies
libssh2_sftp_rmdir_ex(3)					  libssh2 manual					  libssh2_sftp_rmdir_ex(3)

NAME
libssh2_sftp_rmdir_ex - remove an SFTP directory SYNOPSIS
#include <libssh2.h> #include <libssh2_sftp.h> int libssh2_sftp_rmdir_ex(LIBSSH2_SFTP *sftp, const char *path, unsigned int path_len); DESCRIPTION
Remove a directory from the remote file system. sftp - SFTP instance as returned by libssh2_sftp_init(3) sourcefile - Full path of the existing directory to remove. sourcefile_len - Length of the full path of the existing directory to remove. RETURN VALUE
Return 0 on success or negative on failure. It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se. 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_init(3) libssh2 0.15 1 Jun 2007 libssh2_sftp_rmdir_ex(3)
All times are GMT -4. The time now is 06:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy