cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot FTP from Unix to Windows

Raoof
Regular Advisor

Cannot FTP from Unix to Windows

Dear All,

 

Environment Details:

 

Unix : HP-UX B.11.31 U ia64

Windows : XP SP3

 

I cannot able to ftp from unix to windows. When i gave the below command it through an error as

hostname#ftp wind-ipddress

ftp: connect: Connection refused

 

As am new to the Unix box so could able to diagnose the problem much.

 

Will be really grateful for your valuable advices/solutions.

 

Regards

25 REPLIES
Naj
Valued Contributor

Re: Cannot FTP from Unix to Windows

hi,

Please check wind-ipaddress port whether is open or not

#telnet wind-ipaddress (port)

if it remain refuse means wind-ipaddres port ftp is close.

Thanks

BR
Naj

____________________________________________
:: Really appreciate if you could assign some points.
:: Don't know how to assign point? Click the KUDOS! star!
Hein van den Heuvel
Honored Contributor

Re: Cannot FTP from Unix to Windows

>>I cannot able to ftp from unix to windows.

 

Can you FTP to the target box from an other (windows) system?

 

>> hostname#ftp wind-ipddress

>> ftp: connect: Connection refused

 

Typically that is an issue with the target (server/host) box, not the current (client/ftp) box.

Is there an FTP ( IIS ? ) server started on the windows system?

Best I know by default there is no FTP server started on XP

 

>> As am new to the Unix box so could able to diagnose the problem much.

 

It is unlikely to be an Unix issue, an if it is, it is most likely to be a naming issue.

So just tr with a hard coded IP address and/or check with 'ping' an 'nslookup' to make sure the name used actually goes to the right target;

 

Hope this helps some,

Hein

 

Dennis Handly
Acclaimed Contributor

Re: Cannot FTP from Unix to Windows

What's changed since your previous question back in April?  Did it ever work?

http://h30499.www3.hp.com/t5/Networking/Compress-and-FTP-from-HP-UNIX-to-Windows/m-p/4778993#M47418

Gaurab Mallik
Frequent Visitor

Re: Cannot FTP from Unix to Windows

1. check if any FTP server is running on windoesXP box, if not then either you have to enable IIS or use some third party ftp service like filezilla server.

2. Check for firewall issues, port 21 might be blocked from firewall.

3. Use IP address for the windows machine instead of its name.

Unix is user-friendly. It's just very selective about who its friends are
Raoof
Regular Advisor

Re: Cannot FTP from Unix to Windows

Dear Hein,

 

Thanks for your immediate reply.

 

>>Typically that is an issue with the target (server/host) box, not the current (client/ftp) box.

Is there an FTP ( IIS ? ) server started on the windows system?

Best I know by default there is no FTP server started on XP

 

I checked the FTP service in the windows box, yes it was not configured on which I did some work around to get the FTP service enable.

 

Now I can able to FTP from Unix box to the Windows one after facing and resolving the below errors like

Error: 530 User <surname> cannot log in.

Login failed

and

Error: 550 permission denied.

 

But now my concern is to transfer the files 'X & Y' from one of the Unix directory like ( /bkpfiles/X Y ) into the Windows drive (D:\backup\ X Y) by using the shell script which I can scheduled to run on some specific time.

 

Valuable advices will be highly appreciated.

 

Regards

Dennis Handly
Acclaimed Contributor

Re: Cannot FTP from Unix to Windows

>But now my concern is to transfer the files

 

You're script needs to model how you do it by hand.

Did you want to embed the password in your script?

Raoof
Regular Advisor

Re: Cannot FTP from Unix to Windows

Dear Handy,

 

Yes i can add the password in it.

 

 

REgards

Dennis Handly
Acclaimed Contributor

Re: Cannot FTP from Unix to Windows

Some previous threads (that are mangled due to XML tags):

http://h30499.www3.hp.com/t5/System-Administration/Syntax-error-at-line-23-lt-is-not-matched/m-p/4593942/highlight/true#M375231

http://h30499.www3.hp.com/t5/Languages-and-Scripting/ftp-a-file-to-local-system/m-p/4292654/highlight/true#M23033

http://h30499.www3.hp.com/t5/System-Administration/ftp-process/m-p/4204483/highlight/true#M325205

 

(Insert standard caveats about security hole here.)

ftp -n -i machine <<EOF

user user-name password-for-user-name
cd D:\\backup
lcd local-directory
put file
bye
EOF

 

SInce this is windows with their ill advised use of backslashes "\", you will have to quote each one in each command line.

Raoof
Regular Advisor

Re: Cannot FTP from Unix to Windows

Dear Handy,

 

On your given script below

>>

ftp -n -i machine <EOF

user user-name password-for-user-name
cd D:\\backup
lcd local-directory
put file
bye
EOF

 

i did the changes as per my requirement, please check and feedback whether it is in correct format or not, as i am also very newbie in writing the scripts.

 

ftp -n -i machine(here i have to mention the win ipaddress?) <EOF

user administrator test123

cd D:\\backup

lcd /dumps

put file

bye

EOF

 

Please advise.

 

Regards

Dennis Handly
Acclaimed Contributor

Re: Cannot FTP from Unix to Windows

>please check and feedback whether it is in correct format

 

I made a mistake on the here doc format and yes, that's the IP or the DNS name of the windows system.

 

ftp -n -i machine(here i have to mention the win ipaddress?) <<EOF

Raoof
Regular Advisor

Re: Cannot FTP from Unix to Windows

Dear Handy,

 

Thanks for your reply. Please check the below script,

 

Script:

ftp -n -i 10.10.xxx.xxx  <<EOF

user domain"\"syed  test123

cd D:"\"backup   ----windows directory

lcd "/"dumps      -----unix directory

put file.txt

bye

EOF

 

 --- on running the above script i faced the error as

 

$ sh test.sh

D:: The filename, directory name, or volume label syntax is incorrect.

Local directory now /dumps

 

 

Regards

Dennis Handly
Acclaimed Contributor

Re: Cannot FTP from Unix to Windows

Your problem is those evil backslashes.

If you aren't using any "$" variables in your here document, you should quote the here doc "word":

ftp -n -i 10.10.xxx.xxx  <<\EOF

user domain\syed  test123                What you had worked, hopefully this will too.

cd D:\backup   ----windows directory  If this doesn't work, add add another "\" until it does.

lcd /dumps      -----unix directory        No need to quote this, Unix loves slashes.  ;-)

put file.txt

bye

EOF

Raoof
Regular Advisor

Re: Cannot FTP from Unix to Windows

Dear Handy,

 

As per your given steps i run the below script

 

#!/bin/sh
. .oraenv
ftp -n -i 10.10.xxx.xxx <<\EOF
user domain\syed test123                                                                                      
cd D:\                   --- trying to transfer the file directly into D directory                                                                   
lcd /dumps                                                                                                         
put t.dmp
bye
EOF

It gives me below errors.

$ sh tftp.sh
User domainsyed cannot log in. 
Login failed.
Please login with USER and PASS.
Local directory now /dumps
Please login with USER and PASS.

*************************************

 

But when i try to update the script by appending quotations to \

#!/bin/sh
. .oraenv
ftp -n -i 10.10.xxx.xxx <<EOF                                                                                       
user domain"\"syed test123                                                                                   
cd D:"\"
lcd /dumps
put t.dmp
bye
EOF

then i am facing this below error


$ sh tftp.sh
D:\: The filename, directory name, or volume label syntax is incorrect.
Local directory now /dumps

 

Please advice and let me know where exactly am going wrong.

 

Regards

Dennis Handly
Acclaimed Contributor

Re: Cannot FTP from Unix to Windows

>user domain"\"syed test123

 

You might want to change this to:  "domain\syed"      

so it looks better.

 

>cd D:"\"

 

Again, change to: cd "D:\"

And if that fails:

cd D:\

cd D:\\

cd D:\\\

 

>then I am facing this below error

>D:\: The filename, directory name, or volume label syntax is incorrect.

 

Not sure why, when your quote trick worked for your name?

 

>Please advice and let me know where exactly am going wrong.

 

There is no exactly, you just have to experiment until you get it right.

I suppose you could use tusc to see if the shell here-doc is processed correctly.

Raoof
Regular Advisor

Re: Cannot FTP from Unix to Windows

Dear Handy,

 

Even though i append this below commands in quotes i am facing the same old error.

 

D:\: The filename, directory name, or volume lable syntax is incorrect.

 

I tried all the steps i,e by ging "D:/" , "D://", "D:///"  , D:"/",....etc... but still facing the same error.

 

Please advise.

 

Regards

Dennis Handly
Acclaimed Contributor

Re: Cannot FTP from Unix to Windows

>I tried all the steps I,e by giving "D:/" , "D://", "D:///"  , D:"/",.... etc. but still facing the same error.

 

I assume you tried backslashes and not "/"?

You may want to use ftp interactively so you can keep trying various combinations.

Raoof
Regular Advisor

Re: Cannot FTP from Unix to Windows

Dear Handy,

 

 

>> assume you tried backslashes and not "/"?

 

Yes ofcourse i do use backslashes and not "/".

 

>>You may want to use ftp interactively so you can keep trying various combinations.

 

Since from last week i was trying until now, but unable to reach to the good result.

 

Please experts do the needful.

 

Regards

 

Dennis Handly
Acclaimed Contributor

Re: Cannot FTP from Unix to Windows

I created a HP-UX directory: Back\slash

 

Then I used ftp interactively:

$ ftp foo
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /home/bar
250 CWD command successful.
ftp> cd Back\slash
550 Backslash: No such file or directory.
ftp> cd Back\\slash
250 CWD command successful.
ftp> pwd
257 "/home/bar/Back\slash" is current directory.

 

Using a here-doc, this worked:

ftp -n foo <<\EOF
user bar password
cd /home/bar/Back\\slash
pwd
bye
EOF

 

257 "/home/bar/Back\slash" is current directory.

 

Changing above cd also worked:

cd "/home2/dhandly/Back\slash"

Raoof
Regular Advisor

Re: Cannot FTP from Unix to Windows

Now i face some critical issue in my loal pc, i have lost many files from my local pc drive after running this below script.

 

After setting the path to D:\ in FTP SIte Directory location, i  ran the below script.

 

$ vi tftp.sh
"tftp.sh" 9 lines, 122 characters
#!/bin/sh
. .oraenv
ftp -n -i 10.10.xxx.xxx<<EOF
user domai"\"syed test123  ---------------- Here i have connect to windows D:\ drive
lcd /dumpfiles
mput *       ------------ Here files should be transfered from unix to windows D:\ drive
mdelete *   ----------- FIles to be deleted after it get transfered
bye
EOF
 ~
~
"tftp.sh" 13 lines, 134 characters


$ sh tftp.sh
Local directory now/dumpfiles
archive.pst: The process cannot access the file because it is being used by another process.
main_windowl.fmb: Access is denied.
Please have it/MCMS.exe: The process cannot access the file because it is being used by another process.
SharedWork/request_tab_A.rdf: Access is denied.
SharedWork/request_tab_E.rdf: Access is denied.

 

But the script deleted all files from the window drive D:\ , I LOST ALL MY FILES WHICH WAS IN D:\ drive.

 

PLEASE DO THE NEEDFUL, I REALLY NEED THE HELP, I LOST MANY DATA

 

PLEASE EXPERTS HELP ME TO GWT RID OUT FROM THIS LOOS.

 

HOW I CAN ROOLBACK THOSE FILES WHICH WAS DELETED WITH "mdelete *" command...

 

Regards

Pete Randall
Outstanding Contributor

Re: Cannot FTP from Unix to Windows

Unix doesn't have a trash folder.  That's why good administrators do backups.  You'll have to restore them from your backup.


Pete
Dennis Handly
Acclaimed Contributor

Re: Cannot FTP from Unix to Windows

>Unix doesn't have a trash folder.

 

mdelete says: mdelete [remote-files]

 

And if ftp connects to the recycle bin, Raoof is golden, otherwise hosed. :-(

Pete Randall
Outstanding Contributor

Re: Cannot FTP from Unix to Windows

>  Doesn't the "mdelete *" work on the remote windows system?

You probably know better than I, Dennis.  I assumed from the script snippet

 

>>  mput *       ------------ Here files should be transfered from unix to windows D:\ drive
>>  mdelete *   ----------- FIles to be deleted after it get transfered

 

that if the mput was transferring from unix, then the mdelete would be deleting from unix.  If not, then I think we've got a real logic problem in the script because that would mean we're transferring to windows and then immedaitely deleting them from windows.


Pete
Raoof
Regular Advisor

Re: Cannot FTP from Unix to Windows

Dear Pete,

 

Thanks for understanding my situation.

 

>>  mput *       ------------ Here files should be transfered from unix to windows D:\ drive
>>  mdelete *   ----------- FIles to be deleted after it get transfered from unix

 

>>>that if the mput was transferring from unix, then the mdelete would be deleting from unix. 

This is what it made me confused, i was issuing the command to delete the files from unix once it get transfered from UNIX to Widows.

But its not that the case, as you said below

 

>> If not, then I think we've got a real logic problem in the script because that would mean we're transferring to windows and then immedaitely deleting them from windows.

 
It has done the same thing pete, it transfered the files from unix to windows and immediatly after that with
(mdelete *) command deleted all files from the windows drive instead of deleting from the unix, very strange.
 
Please need you valuable advice. I really got hurt with this crap script which got executed in the wrong manner.
 
Regards
Syed
Pete Randall
Outstanding Contributor

Re: Cannot FTP from Unix to Windows

Syed,

 

The obvious answer to your deletion problem is to remove that line from your script and replace it with a "rm" command which you would execute after the ftp session by placing it after the line reading "EOF"


Pete