By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,603 Members | 1,053 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,603 IT Pros & Developers. It's quick & easy.

sftp script

P: 3
hi

i need a script which uses sftp to collect files without “transferred(some)” extension.it will be very much helpful to me
Jan 3 '08 #1
Share this Question
Share on Google+
4 Replies

numberwhun
Expert Mod 2.5K+
P: 3,503
hi

i need a script which uses sftp to collect files without “transferred(some)” extension.it will be very much helpful to me
Ok, it sounds to me like you may have already tried, but are not getting the expected result. Why not post your code here and we can help you.

Regards,

Jeff
Jan 3 '08 #2

P: 3
Ok, it sounds to me like you may have already tried, but are not getting the expected result. Why not post your code here and we can help you.

Regards,

Jeff
Expand|Select|Wrap|Line Numbers
  1. #!bin/ksh
  2. set -x
  3. CONFIG_FILE="./config_file"
  4. hostname=`grep "^hostname" ${CONFIG_FILE} | awk -F":" '{print $2}'`
  5. username=`grep "^username" ${CONFIG_FILE} | awk -F":" '{print $2}'`
  6. password=`grep "^password" ${CONFIG_FILE} | awk -F":" '{print $2}'`
  7. filedirectory=`grep "^filedirectory" ${CONFIG_FILE} | awk -F":" '{print$2}'`
  8. destinationDir=`grep "^destinationdir" ${CONFIG_FILE} | awk -F":" '{print $2}'`
  9. echo $hostname
  10.  
  11. filename=$1
  12. echo $filename
  13.  
  14.  
  15. TMP_DIR=${HOME}/ramu
  16. FTP="/usr/local/bin/sftp ${username}@${hostname}"
  17.  
  18. #
  19. # Load the ssh-agent environment
  20. #
  21. . $HOME/.ssh/.env
  22.  
  23. tmpdir=`dirname ${filename}`
  24. tmpFile=`basename ${filename}`
  25. #audit "Transferring ${filename} to ${destinationDir}/${destinationFileName}"
  26. ${FTP} << EOF >> /dev/null
  27. cd ${destinationDir}
  28. lcd ${tmpdir}
  29. #get ${tmpFile}
  30. put ${tmpFile} ${destinationFileName}
  31. bye
  32.  
here the staring values r taken from config file
Jan 4 '08 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
Expand|Select|Wrap|Line Numbers
  1. #!bin/ksh
  2. set -x
  3. CONFIG_FILE="./config_file"
  4. hostname=`grep "^hostname" ${CONFIG_FILE} | awk -F":" '{print $2}'`
  5. username=`grep "^username" ${CONFIG_FILE} | awk -F":" '{print $2}'`
  6. password=`grep "^password" ${CONFIG_FILE} | awk -F":" '{print $2}'`
  7. filedirectory=`grep "^filedirectory" ${CONFIG_FILE} | awk -F":" '{print$2}'`
  8. destinationDir=`grep "^destinationdir" ${CONFIG_FILE} | awk -F":" '{print $2}'`
  9. echo $hostname
  10.  
  11. filename=$1
  12. echo $filename
  13.  
  14.  
  15. TMP_DIR=${HOME}/ramu
  16. FTP="/usr/local/bin/sftp ${username}@${hostname}"
  17.  
  18. #
  19. # Load the ssh-agent environment
  20. #
  21. . $HOME/.ssh/.env
  22.  
  23. tmpdir=`dirname ${filename}`
  24. tmpFile=`basename ${filename}`
  25. #audit "Transferring ${filename} to ${destinationDir}/${destinationFileName}"
  26. ${FTP} << EOF >> /dev/null
  27. cd ${destinationDir}
  28. lcd ${tmpdir}
  29. #get ${tmpFile}
  30. put ${tmpFile} ${destinationFileName}
  31. bye
  32.  
here the staring values r taken from config file
First, in your SFTP, you are doing a ">> /dev/null". If you put all out put to the bit bucket, how are you supposed to capture and see any errors? The first thing that I would do is to redirect any output to a file that you can parse for errors and see if anything is going awry.

Next, I see that you are using "${HOME}", but I don't see that it is defined before you are using it in the script.

Regards,

Jeff
Jan 4 '08 #4

P: 3
First, in your SFTP, you are doing a ">> /dev/null". If you put all out put to the bit bucket, how are you supposed to capture and see any errors? The first thing that I would do is to redirect any output to a file that you can parse for errors and see if anything is going awry.

Next, I see that you are using "${HOME}", but I don't see that it is defined before you are using it in the script.

Regards,

Jeff
ok yaar i am completely lost can u give me a new script with some idea
regards
ramu
Jan 7 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.