ftp script error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ftp script error
# 1  
Old 10-31-2011
ftp script error

Hi ,

I was writing a bash script of ftp to transfer the files , rite now I am considering my local server as ftp server and through keygen -ssh I ahve generated the public & private keys , the private key I have kept in the folder named scripts where my all scripts resides and the public key in the .ssh folder in the home directory and inside that authorized_keys folder(permission 600) I have kept the public key ... below are the contents of the configuration file as well as main script file

Code:
#############################################

#Properties file for Ftp files

#############################################


#remote url of the machine 
Remoteurl=pngrcdb1.weens.com

#This is the source directoy from where the files will be picked up
SrcFolders=/home/p2000/sxs137/ODS_Project/temp


#This directory path should end with a slash(/)
DestFolder=/home/p2000/sxs137/ODS_Project/test


#the pattern of the files
SourcefilePattern=*.txt


# your user id 
userid=sxsfd45

and below is the main file which reads from the above configuration


Code:
#!/bin/sh
. /home/p2000/sxs137/scripts/archieve1.config

sftp -vin >> ftp.log <<EOF
open $Remoteurl
user $userid 
cd $DestFolder
cd $SrcFolders
put $SourcefilePattern
bye
EOF


Now the problem is that when I execute this script it shows the error ..!!
# 2  
Old 10-31-2011
What is the error you are getting? Post the error.

--ahamed

Last edited by ahamed101; 10-31-2011 at 06:17 AM..
# 3  
Old 10-31-2011
Quote:
Originally Posted by ahamed101
What is the error you are getting? Post the error. And I don't see "$userid" defined anywhere.

--ahamed
Hi,

below is the error .....


Code:
[sxs137@pngpcdb1 scripts]$ ./main1.sh
: command not foundscripts/archieve1.config: line 2:
: command not foundscripts/archieve1.config: line 4:
: command not foundscripts/archieve1.config: line 6:
: command not foundscripts/archieve1.config: line 7:
: command not foundscripts/archieve1.config: line 10:
: command not foundscripts/archieve1.config: line 13:
: command not foundscripts/archieve1.config: line 14:
: command not foundscripts/archieve1.config: line 17:
: command not foundscripts/archieve1.config: line 18:
: command not foundscripts/archieve1.config: line 21:
: command not foundscripts/archieve1.config: line 22:
: command not foundscripts/archieve1.config: line 25:
./main1.sh: line 3: Remoteurl: command not found
: [sxs137@pngpcdb1 scripts]$

# 4  
Old 10-31-2011
Please check your archieve1.config file. Make sure yuo don't have a "$" sign infront of the variables.
i.e. This is wrong
$Remoteurl=pngrcdb1.weens.com

This is correct!
Remoteurl=pngrcdb1.weens.com

I don't see any other issues here.

--ahamed

---------- Post updated at 02:22 AM ---------- Previous update was at 02:19 AM ----------

Ohh... wait... I think the issue is with the blank lines in the archieve1.config file.
Try removing the blank lines and try. Post the output of od -bc /home/p2000/sxs137/scripts/archieve1.config

--ahamed
# 5  
Old 10-31-2011
Quote:
Originally Posted by ahamed101
Please check your archieve1.config file. Make sure yuo don't have a "$" sign infront of the variables.
i.e. This is wrong
$Remoteurl=pngrcdb1.weens.com

This is correct!
Remoteurl=pngrcdb1.weens.com

I don't see any other issues here.

--ahamed

---------- Post updated at 02:22 AM ---------- Previous update was at 02:19 AM ----------

Ohh... wait... I think the issue is with the blank lines in the archieve1.config file.
Try removing the blank lines and try. Post the output of od -bc /home/p2000/sxs137/scripts/archieve1.config

--ahamed

Hi ,

the ouput of the
Code:
od -bc /home/p2000/sxs137/scripts/archieve1.config

is below....


Code:
$ od -bc /home/p2000/sxs137/scripts/archieve1.config
0000000 043 043 043 043 043 043 043 043 043 043 043 043 043 043 043 043
          #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #
*
0000040 043 043 043 043 043 043 043 043 043 043 043 043 043 015 012 015
          #   #   #   #   #   #   #   #   #   #   #   #   #  \r  \n  \r
0000060 012 043 120 162 157 160 145 162 164 151 145 163 040 146 151 154
         \n   #   P   r   o   p   e   r   t   i   e   s       f   i   l
0000100 145 040 146 157 162 040 106 164 160 040 146 151 154 145 163 015
          e       f   o   r       F   t   p       f   i   l   e   s  \r
0000120 012 015 012 043 043 043 043 043 043 043 043 043 043 043 043 043
         \n  \r  \n   #   #   #   #   #   #   #   #   #   #   #   #   #
0000140 043 043 043 043 043 043 043 043 043 043 043 043 043 043 043 043
          #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #
*
0000200 015 012 015 012 015 012 043 162 145 155 157 164 145 040 165 162
         \r  \n  \r  \n  \r  \n   #   r   e   m   o   t   e       u   r
0000220 154 040 157 146 040 164 150 145 040 155 141 143 150 151 156 145
          l       o   f       t   h   e       m   a   c   h   i   n   e
0000240 040 015 012 122 145 155 157 164 145 165 162 154 075 160 156 147
             \r  \n   R   e   m   o   t   e   u   r   l   =   p   n   g
0000260 160 143 144 142 061 015 012 015 012 043 040 171 157 165 162 040
          p   c   d   b   1  \r  \n  \r  \n   #       y   o   u   r
0000300 165 163 145 162 040 151 144 040 015 012 165 163 145 162 151 144
          u   s   e   r       i   d      \r  \n   u   s   e   r   i   d
0000320 075 163 170 163 061 063 067 015 012 015 012 015 012 043 124 150
          =   s   x   s   1   3   7  \r  \n  \r  \n  \r  \n   #   T   h
0000340 151 163 040 151 163 040 164 150 145 040 163 157 165 162 143 145
          i   s       i   s       t   h   e       s   o   u   r   c   e
0000360 040 144 151 162 145 143 164 157 171 040 146 162 157 155 040 167
              d   i   r   e   c   t   o   y       f   r   o   m       w
0000400 150 145 162 145 040 164 150 145 040 146 151 154 145 163 040 167
          h   e   r   e       t   h   e       f   i   l   e   s       w
0000420 151 154 154 040 142 145 040 160 151 143 153 145 144 040 165 160
          i   l   l       b   e       p   i   c   k   e   d       u   p
0000440 015 012 123 162 143 106 157 154 144 145 162 163 075 057 150 157
         \r  \n   S   r   c   F   o   l   d   e   r   s   =   /   h   o
0000460 155 145 057 160 062 060 060 060 057 163 170 163 061 063 067 057
          m   e   /   p   2   0   0   0   /   s   x   s   1   3   7   /
0000500 117 104 123 137 120 162 157 152 145 143 164 057 164 145 155 160
          O   D   S   _   P   r   o   j   e   c   t   /   t   e   m   p
0000520 015 012 015 012 015 012 043 124 150 151 163 040 144 151 162 145
         \r  \n  \r  \n  \r  \n   #   T   h   i   s       d   i   r   e
0000540 143 164 157 162 171 040 160 141 164 150 040 163 150 157 165 154
          c   t   o   r   y       p   a   t   h       s   h   o   u   l
0000560 144 040 145 156 144 040 167 151 164 150 040 141 040 163 154 141
          d       e   n   d       w   i   t   h       a       s   l   a
0000600 163 150 050 057 051 015 012 104 145 163 164 106 157 154 144 145
          s   h   (   /   )  \r  \n   D   e   s   t   F   o   l   d   e
0000620 162 075 057 150 157 155 145 057 160 062 060 060 060 057 163 170
          r   =   /   h   o   m   e   /   p   2   0   0   0   /   s   x
0000640 163 061 063 067 057 117 104 123 137 120 162 157 152 145 143 164
          s   1   3   7   /   O   D   S   _   P   r   o   j   e   c   t
0000660 057 164 145 163 164 015 012 015 012 015 012 043 164 150 145 040
          /   t   e   s   t  \r  \n  \r  \n  \r  \n   #   t   h   e
0000700 160 141 164 164 145 162 156 040 157 146 040 164 150 145 040 146
          p   a   t   t   e   r   n       o   f       t   h   e       f
0000720 151 154 145 163 015 012 123 157 165 162 143 145 146 151 154 145
          i   l   e   s  \r  \n   S   o   u   r   c   e   f   i   l   e
0000740 120 141 164 164 145 162 156 075 052 056 164 170 164 015 012 015
          P   a   t   t   e   r   n   =   *   .   t   x   t  \r  \n  \r
0000760 012 015 012 015 012 015 012
         \n  \r  \n  \r  \n  \r  \n
0000767

please guide me how to resolve this so that sftp script above can work..!1 Thanks in advance
# 6  
Old 10-31-2011
Remove the \r usig the following command...
Code:
dos2unix /home/p2000/sxs137/scripts/archieve1.config

And then try your script!

--ahamed
# 7  
Old 10-31-2011
Quote:
Originally Posted by ahamed101
Remove the \r usig the following command...
Code:
dos2unix /home/p2000/sxs137/scripts/archieve1.config

And then try your script!

--ahamed
Hi ,
Thanks as guided by you I have removed the white spaces ....thruough that same command ....since I am considering the my present machine as ftp one itself ...it is showing me the following errors...


Code:
ftp: bind: Address already in use
$
  From Secure4Access server process at 31-Oct-11  04:52...
                                                          Your session is inactive and will be terminated in one minute.

     From Secure4Access server process at 31-Oct-11  04:53...
                                                             Your session has become inactive and is being terminated.
   tcsetattr: Interrupted system call
                                     Killed by signal 1.
tcsetattr: Interrupted system call
                                  `sxs137' logout from `pngpcdb1' at 31-Oct-11  04:53, connect time: 0:31
                                                                                                         Connection to pngpcdb1 closed.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script FTP maintain error handling

Hi, I have ftp script like below How to insert an error handling, If the transfer failed then send mail to me. Actually, I just need the script to send an email if the FTP failed. How to put the email script within FTP script? Thank You Edy (5 Replies)
Discussion started by: edydsuranta
5 Replies

2. Shell Programming and Scripting

Help with FTP Script which is causing "syntax error: unexpected end of file" Error

Hi All, Please hav a look at the below peice of script and let me know if there are any syntax errors. i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
Discussion started by: mahi_mayu069
1 Replies

3. AIX

FTP Script error - AIX

Hi, I'm trying to create a ftp script so I can make an ftp connection and start upload and download files from/to remote servers. In this case I want to start a connection (crontab) and transfer files from localserver1 to remoteserver; remoteserver to localserver1; finally from localserver1... (3 Replies)
Discussion started by: marques_rmc
3 Replies

4. Shell Programming and Scripting

end of file error bash ftp script

Hello kind programmers :) I am a newbie and running into an error "line 28: syntax error: unexpected end of file" on the script shown below. Any help would be greatly appreciated. Thanks! #! /bin/bash if ($#argv <3) then echo 'Usage get_modis_snow ' echo 'ftp script for MYD10A2... (2 Replies)
Discussion started by: cmshreve
2 Replies

5. Shell Programming and Scripting

FTP script error in BASH

Hi All, I have a script which is supposed to connect to Windows machine and FTP a file into LINUX. Script is like below #!/usr/bin/sh ParamterFle=${1} //grepping all parameters BossFtpLog=${2} // assigning log file ftp -i -n host_name << EOF user1 password1 cd /drive1/drive2 get... (6 Replies)
Discussion started by: Raamc
6 Replies

6. Shell Programming and Scripting

FTP script error

This question has been answered many times. I tried to use some examples. Here is the error and cannot find the reason. Please help! messages : 40 step1 step2 arcfile1.sh: line 55: syntax error: unexpected end of file :( here is the script: #!/bin/bash DATE=`date +%Y%m%d`... (21 Replies)
Discussion started by: Lenora2009
21 Replies

7. Shell Programming and Scripting

Does not exist or unreadable error in windows ftp script

I have a file like this 07200900.SUP,in a windows directory I need to FTP this file to UNIX , the directory in unix is N:\orgs\Financial Aid\MIIS\0910\FTP I am getting this error miis_ftp.ELM_SUP.shl: =cd orgs/"Financial Aid"/"MIIS"/"0910"/"FTP" : not found IN THE LOG FILE Activities for Mon... (3 Replies)
Discussion started by: rechever
3 Replies

8. Shell Programming and Scripting

FTP script error

Hi all, I am trying to run a FTP script which would go to diff servers in the environment and get the request logs and I am getting the following error, Please let me know. server1.ou.st.com (to) usage: open host-name Not connected. Local directory now /home/pk960/logs Not connected.... (0 Replies)
Discussion started by: crosairs
0 Replies

9. Shell Programming and Scripting

FTP shell script error caturing

Hello All, Can anyone let me know how to capure errors in shell scripting? n even the error considerations? Like -- - File not found what other errors can occure in that n how those could be captured? Im_new (6 Replies)
Discussion started by: im_new
6 Replies

10. UNIX for Dummies Questions & Answers

Error in execting ftp script

Please find the below script: #!/bin/ksh host='gskprod.xyz.com' USER='gsk' PASSWORD='ahdpw1' remote_dir='gsk_ds' ftp -n "${host}" user $USER $PASSWORD binary cd $remote_dir mget *.txt mdelete *.txt bye It does not recognizes userid and password. It executes... (4 Replies)
Discussion started by: jhmr7
4 Replies
Login or Register to Ask a Question