This little script is used to copy my Netscape Navigator bookmark.htm file from my laptop running NT to my bsd box at home.
There are two problems with it:
1: I need to set it up so I can pipe in a file of different machine names so it will update all of my machines.
2: I need to tweak it so it will do some sort of file globbing. Right now the only way I can make it work is to put it in the same directory as the bookmarks file. (I couln't figure out how to get the absolute path (Program Files/Netscape/Users/default as the path) Any ideas on what would be the best way to get the program files directory name? Would a glob be best?
Answer to number 2- bad scotstef! bad scotstef! Did a perl monks search on dos file spaces and i think vroom had posted this a year ago. WOW rtfm worked. Sorry I should have done that earlier.
Answer to number 1- will work on it, just need to test which boxes i want to send to.
#!/usr/bin/perl -w
use strict;
use Net::FTP;
#Written by Scott for the purpose of saving having
#to manually copy over my bookmarks file from my laptop.
#variables to define the server, username,
#password, local bookmarks file, remote bookmarks file,
#and the "ftp object"?
my $server="hostname.com";
my $username="username";
my $password="password";
my $file= "c:\\Program Files\\Netscape\\Users\\default\\bookmark.htm";
my $bookmarks="/home/scott/.netscape/bookmarks.html";
my $ftp;
#Create the connection
$ftp=Net::FTP->new($server);
#print statement- always like a lort of these so i know something
#happenned, is happening etc
print "Trying to log in\n";
#log in or Die- tells me i was unable to log in
$ftp->login($username, $password) || die "Unable to log in: $!";
#see comment on print statements for below.
print"Succesful log in\n";
#actually starting the xfer through a put statement putting local file
+s over to
#remote file name
#Use Die to let me know i screwed up the xfer
$ftp->put($file, $bookmarks) || die "Unable to upadate files";
#Quit nicely, or Die and quit forcefully
$ftp->quit() || die "Unable to quit $!";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.