- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl and FTP
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2008 11:12 AM
тАО09-15-2008 11:12 AM
I was wondering if there is away I can have the script detect the file type ( Binary or ASCII) automatically?
I am putting the FTP server login in credentials in the script. Is there any way to hide/encrypt the password field?
Is there any way to encrypt a perl script so if someone wants to open it for read will ask some password however the script is executable anyway?
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2008 12:41 PM
тАО09-15-2008 12:41 PM
Solution--8<---
use Net::FTP;
use Net::Netrc;
my ($host, $u, $p) = ("some.host.com", "username");
if (my $machine = Net::Netrc->lookup ($host)) {
($u, $p) = $machine->lpa;
}
my $ftp = Net::FTP->new ($host, Passive => 1) or die "Connect failed: $@";
$ftp->login ($u, $p) or die "login: " .$ftp->message;
$ftp->binary or die "binary: " .$ftp->messgae;
-->8---
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2008 06:32 PM
тАО09-15-2008 06:32 PM
Re: Perl and FTP
There isn't any method to detect ASCII except to guess. The problem is that BINARY is an ftp protocol that simply sends exactly what is on the source and stores it the same way on the destination. An ASCII transfer is much more complicated to accommodate the myriad of differences between OS file formats. In the code, the source file is read one record at a time with the record defined by the source system. This record is sent with length information so that that receiving side can add whatever special code(s) are needed to form an "ASCII" file on the destination system. Mainframes have dozens of specialized formats so ASCII can be quite useful in transferring text files.
But the definition of an ASCII file, especially in Unix is quite convoluted. A Postscript file is ASCII but technically, a PCL file is mostly ASCII with escape sequences. An awk or Perl script is ASCII but a library file or executable is binary but of dubious value on another system. So the decision must be made based on the purpose and usage of the file.
> credentials in the script
Why worry about it? Anyone can sniff the network and see the plain text login and password. That's why ftp is deprecated for secure data transmissions or at least limited to FTP-only chroot accounts.
If you have no choice in FTP, consider using $HOME/.netrc to hide the login/password outside the script. This is only a trivial mechanism because the script must be run by the user with the $HOME/.netrc file.
The ideal method is scp or sftp using public key exchange. In this way, no user or password is visible during the negotiation and the data is protected.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-29-2008 06:57 PM
тАО09-29-2008 06:57 PM
Re: Perl and FTP
Any comment on the encrypting a perl script?
Thanks again for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2008 03:45 AM
тАО09-30-2008 03:45 AM
Re: Perl and FTP
> Is there any way to encrypt a perl script so if someone wants to open it for read will ask some password however the script is executable anyway?
By using the Net::Netrc module you don't have a plaintext password in the Perl script itself, so there is no danger in seeing the script's contents.
In lieu of FTP, you could easily change to SFTP using Perl's Net::SFTP::Foreign module. Fetch it and read its documentation here:
http://search.cpan.org/~salva/Net-SFTP-Foreign-1.43/lib/Net/SFTP/Foreign.pm
Regards!
...JRF...