Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applications FTP'd through PERL won't execute 2

Status
Not open for further replies.

rickgerdes

IS-IT--Management
Feb 11, 2003
44
US
Hey folks, anyone seen or heard of this one?

I ftp an application from a remote site to the server running a perl application (Net::FTP). The application then won't run.
Win32 (NT box) platform. Suggestions as to why this is happening appreciated. I'm not doing anything fancy, open ftp connection, login, get file, close ftp.

Thanks in advance!
 
What type of transfer, ascii, binary, auto?
Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
I've tried ascii and setting the type to binary. Doesn't seem to make a difference.

For the record, NT box for FTP server, NT for script and receiver.
 
"The application then won't run." is not very helpful to us. You ought to get some kind of errors, which would be a lot more useful to us. Also, to find out if the problem is in the transfer or has to do with the box itself simply chekc what the script looks like once transfered on the remote box. Start with a small and simple script to figure out where the problem occurs.
 
Here's a chunk of the current code:

$ftp = Net::FTP->new($host);
$ftp->login($user,$pass);
$ftp->cwd($home);
$ftp->put($datafile);
$ftp->cwd('..\\update');
@upd=$ftp->ls;
foreach $l (@upd) { if ($l =~ /autotest.exe/) { $ftp->get("autotest.exe") } }
$ftp->quit;

Push up a file, then look for a file named autotest.exe, if it exists, get it. But once gotten, it won't run. If it were UNIX I'd wonder about execute permission, but this is NT...
 
Sorry, I'm not being clear.

The retreived application will not run.

The script itself runs fine, but the file it retrieves will not execute after being downloaded.
 
Rick,

You're going NT to NT?

Have you tried ftp through a console window?
Have you compared the file attributes on both machines, and they are identical including the sizes etc?

I saw one like that here a while ago, but can't find it, sorry

Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
ok... again. "The retreived application will not run." is no more useful than "The application then won't run." What is the error? I understand the part that it's the script that transfer that has problems but rather the script being transfered. Start transferring small and simple script for troubleshooting purpose if the one oyu are currently trying to upload is too big.
 
In my previous message I said "I understand the part that it's the script that transfer that has problems but rather the script being transfered." but meant "I understand the part that it's not the script that transfer that has problems but rather the script being transfered."
 
If I had more, I'd give it to you. When the program is called, the computer spins its wheels and then ignores the request. It simply refuses to execute.

Running the ftp from a console works fine, the application runs. It's only when pulled from within the script that the app won't execute.
 
I'm sorry but it's not being clear to me what kind of apps you are transfering. Are those apps binaries? i.e. .exe files? If so then make sure you set the file handle to binmode when reading the file and trasnfering the file. BTW, did you write that trasfering perl script yourself?
 
Back up, reset, start from scratch-

I wrote a perl script to wander through a lot of stuff on an NT box, write it all down in a log file, ftp it up to a server. After it's been uploaded, check for a newer copy of the executable (perl2exe) and download it. Next time the logger gets called it looks to see if it downloaded a new copy and if it did, back itself up and move the new copy into position and start up.

The logging works perfect. I'm pushing data from 10 servers to a central site, that site has a perl script to pull specific bits of the code out and pass the numbers to MRTG and display things that aren't necessarily graphical (Did the backup run? did our database rebuild last night, etc.) We are about to roll out the code to another 50 servers, but I want to be able to update a single location and have the executables in the field do their own updates.

Make more sense now? The application isn't transferring correctly though. It doesn't display in NT as being a compiled PERL app (no icon) so something is being lost in translation.

Does any of this help?

And I pulled bits and pieces of the script from a half dozen locations, put it all together and the full file is now over five hundred lines long. Mostly slef coded from other examples. Some day I'll actually study the language, till then I'm too busy trying to write in it if you know what I mean. :)
 
I have a fair idea of what the problem is. By now it's clear that the problem is in the script that transfers the files. It does something to those files that cause them to just hang if you try to run them. So, my question was if those files beeing transfered were execuables (binaries), and now I know they are. Obviously something is happening during transfer. I say, to have a clue of what or how it screws the file being transfered, use a smaller and simplier file and then look at it for anomalies once transfered. That will give you a hint as to what is wrong. I suspect that you are not setting some file handle to binmode, which I've mentioned earlier.
 
I updated the ftp code to include the line:

$ftp->binary();

And I'm running a test now. I had this earlier, but I hadn't witnessed a change. If this works I'll put myself out there for a blockhead award.

I'll also have to start another thread about cleaning up some ugly filtering code I have. I know you experts can do in one line what takes me a half page. ;)
 
Alright, as I said- blockhead award.

$ftp->binary(); did the trick apparently.
Now I'm just massaging the code to do the automatic file shuffle, no big deal.

Thanks folks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top