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
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 09:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy