Unix FTP Script connecting through proxy Not working


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Unix FTP Script connecting through proxy Not working
# 1  
Old 02-04-2010
Question Unix FTP Script connecting through proxy Not working

Hi All,
can some one please help me to solve this issue, its urgentSmilie
We need to FTP a file form our Unix server to an external client FTP location.
I am trying to connect to the proxy server first and then use the below USER comment to connect to the external FTP server, and its working correctly when I am doing it manually
user <userid>@<ftpservername> <password>
But when I try to user the same comment in a shell script its not working.
Can some one please tell me whether this type of connection is possible from the script.

Script code
#!/bin/sh
ftp -n <proxy server addres> <<END_SCRIPT
quote USER '<userid>'
quote PASS '<password>'
user <remote user id>@<remote sever name> <password>

Please see the error below that I am getting when I run the script

ERROR LOG
Connected to ftp-gw.glb2.hedani.net.
220 Welcome to the <company name>....
331 Enter authentication password for user id
230 User authenticated to proxy
331-(----GATEWAY CONNECTED TO <enternal server name>----)
331-(220-Microsoft FTP Service)
331-(220 Lighthouse FTP - Accesses and activities are logged. Illegitimate reque
sts for service will result in legal action.)
331 Password required for <remote user id>.
530 User <remote user id> cannot log in.
Login failed.
530 Please login with USER and PASS.
221 Goodbye!

thanks for your help
Joseph
# 2  
Old 02-04-2010
Does the last password need to be on a new line perhaps?, e.g.:
Code:
#!/bin/sh
ftp -n <proxy server addres> <<END_SCRIPT
quote USER '<userid>'
quote PASS '<password>'
user <remote user id>@<remote sever name> 
<password>
END_SCRIPT

The end of the heretext was also missing, if that still does not work i would try using expect(1) instead of heretext, something like:

Code:
#!/usr/bin/expect
spawn ftp -n <proxy server address>
epect "Name"
send "USER <userid>\r"
expect "password for user id"
send "<password>\r"
expect "to proxy"
send "user <remote user id>@<remote sever name> \r"
expect "Password required for"
send "<password>\r"

(other commands or interact)

expect eof

What to expect(1) will need amending to what appears on the screen before each response but you'll get the gist of what I am trying to do above.
# 3  
Old 02-04-2010
Code:
#!/bin/sh
ftp -n <proxy server addres> <<END_SCRIPT
quote USER '<userid>'
quote PASS '<password>'
user <remote user id>@<remote sever name> <password>

As TonyFullerMalv has spotted the above script contains spurious "quote" statements. He has also spotted that the END_SCRIPT termination line for the unix here document is missing.

Personally I would use a ".netrc" file to provide the username and password for the connection to the proxy server and then present the "user" line within a unix here document.
# 4  
Old 02-05-2010
Double post, continued here. Thread closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP script not working

Hi , Hi , seems in my code '\' is ignoring in user id and considering DB_SVCGPRUAT as a ID and failing to connect to the FTP server. my complete ID 'BD\SVCGPRUAT', how to rectify this error. #!/bin/bash myuser='"BD\_SVCGPRUAT" { BD is domain } mypass='Welcome$123'... (4 Replies)
Discussion started by: Riverstone
4 Replies

2. IP Networking

Connecting via proxy chain to Upstream proxy

I need to configure a proxy on my local machine to use an upstream proxy (installed on another machine). The upstream proxy requires Digest/NTLM authorization. I want the local proxy to deal with the upstream proxy's authorization details and provides authorization free access to users that connect... (0 Replies)
Discussion started by: Russel
0 Replies

3. Shell Programming and Scripting

Connecting to Windows server from UNIX through script

I am trying to connect to a Windows server say 10.1.1.10. This servers has a folder named RAJ in which there are multiple .zip files. All these zip files contain a text file called XYZ.txt. Now i have to merge the content of these XYZ.txt files from each of the .zip file and create a new text... (1 Reply)
Discussion started by: swapniljadav
1 Replies

4. Shell Programming and Scripting

FTP using script not working (for transfering file from a remote unix server to windows PC.)

hi, Im using the following code for FTP #!/usr/bin/ksh ftp -v -n "10.29.45.11" << cmd user "mahesva" "mahesva123" get rtl.tar quit cmd Below is the log when i run the above code ********************************** Connected to 10.29.45.11. 220 (vsFTPd 2.0.1) 530 Please login with USER... (20 Replies)
Discussion started by: dll_fpga
20 Replies

5. Shell Programming and Scripting

Script not working after FTP

Hi Gurus, I prepared a script to process some files and then ftp the output file to mainframe directory. Here is the code snippet for the same. # Perform FTP echo "put $TGT_DR/$K.$F.$I.$K1.$RUN_TYPE '$K.$F.$I.$K1.$RUN_TYPE'" >> $LogFile ftp -i -n <<EOF >> $LogFile open... (2 Replies)
Discussion started by: svajhala
2 Replies

6. SCO

SCO UNIX ftp - weird kind of working

hi, i am working on sco unix 5.07, i have 10 individual servers networked locally in which sco os is installed. one of them is not transferring the file to other servers but accepting all files. means Server (A) can accept the file through FTP from any server but not transferring FTP its own... (9 Replies)
Discussion started by: aafflatoon
9 Replies

7. UNIX for Advanced & Expert Users

Trouble connecting to FTP proxy server

Hi Guys, I have trouble connecting to ftp server. My task is to connect to the proxy server and get the latest file to the local machine. It works fine when i do the same steps manually. I've been trying to do it in multiple ways but im just not able to connect. When i check the log, this is what... (4 Replies)
Discussion started by: stunnerz_84
4 Replies

8. Shell Programming and Scripting

ssh script for connecting unix system.

Hi All, I've a log file call netbackup.log in all the 5 servers in location usr/netbackup.log. I dont want to login in each server and check the log file. So i wanted to have a script written to have the log information at one place. I want to have the last 2 lines from the file... (2 Replies)
Discussion started by: suri.tyson
2 Replies

9. Shell Programming and Scripting

connecting to remote db from unix script

Hi everybody, My bash script is trying to connect to a remote database using the 'sqlplus' binary.For this i set(export) the variable TWO_TASK to the value of database name excluding the dot extension part. Can anyone explain me what's the significance of this TWO_TASK variable while... (8 Replies)
Discussion started by: DILEEP410
8 Replies

10. Shell Programming and Scripting

FTP script not working

hi I have made d below ftp script but the last part of script ie. moving the files after transfer (to a location in the source server only) is not working for me. Can anybody pls..help.in same..!!! ####################################################### #!/bin/sh ftp -n 10.209.13.11... (2 Replies)
Discussion started by: rookie250
2 Replies
Login or Register to Ask a Question