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
CURLOPT_QUOTE(3)					     curl_easy_setopt options						  CURLOPT_QUOTE(3)

NAME
CURLOPT_QUOTE - (S)FTP commands to run before transfer SYNOPSIS
#include <curl/curl.h> CURLcode curl_easy_setopt(CURL *handle, CURLOPT_QUOTE, struct curl_slist *cmds); DESCRIPTION
Pass a pointer to a linked list of FTP or SFTP commands to pass to the server prior to your request. This will be done before any other commands are issued (even before the CWD command for FTP). The linked list should be a fully valid list of 'struct curl_slist' structs properly filled in with text strings. Use curl_slist_append(3) to append strings (commands) to the list, and clear the entire list after- wards with curl_slist_free_all(3). Disable this operation again by setting a NULL to this option. When speaking to a FTP server, prefix the command with an asterisk (*) to make libcurl continue even if the command fails as by default libcurl will stop at first failure. The set of valid FTP commands depends on the server (see RFC959 for a list of mandatory commands). The valid SFTP commands are: chgrp group file The chgrp command sets the group ID of the file named by the file operand to the group ID specified by the group operand. The group operand is a decimal integer group ID. chmod mode file The chmod command modifies the file mode bits of the specified file. The mode operand is an octal integer mode number. chown user file The chown command sets the owner of the file named by the file operand to the user ID specified by the user operand. The user operand is a decimal integer user ID. ln source_file target_file The ln and symlink commands create a symbolic link at the target_file location pointing to the source_file location. mkdir directory_name The mkdir command creates the directory named by the directory_name operand. pwd The pwd command returns the absolute pathname of the current working directory. rename source target The rename command renames the file or directory named by the source operand to the destination path named by the target op- erand. rm file The rm command removes the file specified by the file operand. rmdir directory The rmdir command removes the directory entry specified by the directory operand, provided it is empty. statvfs file The statvfs command returns statistics on the file system in which specified file resides. (Added in 7.49.0) symlink source_file target_file See ln. DEFAULT
NULL PROTOCOLS
SFTP and FTP EXAMPLE
TODO AVAILABILITY
SFTP support added in 7.16.3. *-prefix for SFTP added in 7.24.0 RETURN VALUE
Returns CURLE_OK SEE ALSO
CURLOPT_POSTQUOTE(3), CURLOPT_PREQUOTE(3), libcurl 7.54.0 February 25, 2016 CURLOPT_QUOTE(3)
All times are GMT -4. The time now is 07:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy