Perl: Sending file from UNIX server to Windows server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl: Sending file from UNIX server to Windows server
# 1  
Old 11-12-2010
Perl: Sending file from UNIX server to Windows server

I'm trying to write a Perl script where a file from a UNIX server box connects to a Windows server box and copies that file into the Window box.
The main problem I have right now is that whenever I try to connect to the Windows box, the connection is refused.

The error message that always pops up is:
cannot connect to host name: Net::FTP: connect: Connection refused at transfer.pl line 16.

My code is essentially this:

Code:
#!/user/bin/perl -w

use strict;
use Net::FTP;

my $directory = `pwd`;
chomp($directory);
$directory .= "/";

#print "Give name of file being transferred:\n";
#chomp($directory .= <>);

my $host = '<server name or ip address>';

my $ftp = Net::FTP->new($host, Debug => 0) or die "cannot connect to host name: $@";
$ftp->quit;

Any thoughts as to why this would happen (ex. firewall issues)?
For the host name, I use the domain name (both the short and full versions) and the actual IP address, but all of them have the same error message.
Many thanks!
# 2  
Old 11-12-2010
First choose a protocol, ssh2 (scp2) is a great first choice, but you seem to be using ftp. There is the mount flavored family like NFS and SAMBA, file only tools like ftp, and file/command tools like rcp/rsh, scp/ssh/sftp, ssh2/scp2/sftp2. There are services, like http, you could create to facilitate this. There are often perl extensions to allow you to do these inside perl.

Get the protocol working from the command line before getting into code with it.
# 3  
Old 11-12-2010
Unix - Windows FTP Transfer Perl

Some Suggestions.

1. Turn the "Debug" Param on:
Code:
Debug => 1

2. Set it to "2" if that shows more output ( it does with Net::SSH::Perl ) e.g.
Code:
Debug => 2

3. Check if you can login to the win machine from the unix machine on the command line
Code:
  you@unixbox: ftp ftp.winbox.net

4. if not telnet to port 21 ( the FTP command channel )
Code:
  you@unixbox: telnet ftp.winbox.net 21

5. if not see if anything is getting through to the windows box.
Code:
 you@unixbox: /usr/bin/nmap -T5 ftp.winbox.net -p 0-1024

( if you don't have nmap installed install it with apt-get install nmap or yum install nmap. )

Let us know what happened. Good luck.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Do I require remote login access to a windows server to transfer files from a UNIX server

Hi All I need to transfer a file from a UNIX server to a windows server. I saw that it is possible to do this using scp command by looking at the forum listed below: ... (2 Replies)
Discussion started by: vx04
2 Replies

2. Shell Programming and Scripting

Script to communicate from UNIX server to windows server

I have two servers linux and windows and i want to compare files which are in unix server that to windows server and find out which are missing that means i have 50 files with 6000 records in each file on linux server and i want to verify weather these 50 files are present in windows server... (5 Replies)
Discussion started by: sagar_1986
5 Replies

3. Solaris

FTP-ing files from Windows server to UNIX server

I need to transfer files from a Windows server to the Unix server and have to run some shell script on it to get the required output. Is it possible to transfer files from Windows server to unix server through any shell script? If so can you please help me with the details. Thanks in... (8 Replies)
Discussion started by: ssk250
8 Replies

4. Shell Programming and Scripting

Needed SFTP script from windows to UNIX server and from UNIX to windows server(reverse SFTP)

hi guys, i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not and again i have to reverse sftp the files from unix to windows server..... regards, Vasa Saikumar. (13 Replies)
Discussion started by: hemanthsaikumar
13 Replies

5. Programming

Problem with Perl script after moving from a Windows/Apache Server to a UNIX server.

I have a Perl script that worked fine before moving it to justhost.com. It was on a Windows/Apache server. Just host is using UNIX. Other Perl scripts on other sites that were also moved work fine so I know Perl is functioning. The script is called cwrmail.pl and is located in my cgi-bin. When I... (9 Replies)
Discussion started by: BigBobbyB
9 Replies

6. Shell Programming and Scripting

Unix shell script to Copy files from one Windows server to another Windows server.

Can anybody please help me on how to code for the below requirement: I need to write a shell script (on different unix server) to copy files from multiple folders (ex. BRN-000001) from one windows server (\\boldls-mwe-dev4)to a different windows server(\\rrwin-ewhd04.ecomad.int). This shell... (4 Replies)
Discussion started by: SravsJaya
4 Replies

7. Shell Programming and Scripting

Perl and sending file to server

Hi, I am trying to write some test code for bigger project where my perl script will send file over to server. This is the current SERVER and CLIENT code I have so far. When I type "hi" from client I get hello back from server and like wise I send send command I get respond back the problem... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

8. Shell Programming and Scripting

FTPing files from unix server to windows server

Hi, Below is the script which ftps the file from unix server and putting in a different directory(but on unix server) How can i ftp the files from unix server and to place in a secure location on windows server? what changes needs to be done to the below script? How can this be... (1 Reply)
Discussion started by: venkatesht
1 Replies

9. UNIX for Dummies Questions & Answers

Script runs fine on UNIX Server...Not through MSK Tool kit on Windows Server

I have a .sh script which was running fine on all the UNIX Servers (AIX, SunSolaris). The script requires two mandatory parameters and many optional parameters. Now at a different client place who are on a Windows Server, when I try to execute the script through MKS Toolkit, there are couple of... (5 Replies)
Discussion started by: madhunk
5 Replies

10. Shell Programming and Scripting

FTP script for sending a file from one unix directory to another unix server director

Hi, My local server is :/usr/abcd/ Remote server is :/Usr/host/test/ I want to send files from local unix directory(All files starting with O_999) to remote host unix directory. Can any body give me the Unix Shell script to do this. One more doubt: Shall we need to change the file... (1 Reply)
Discussion started by: raja_1234
1 Replies
Login or Register to Ask a Question