 |
 |
How to get URL info out of .webloc files in the shell ???
|
 |
|
 |
|
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status:
Offline
|
|
I have quite a collection of links on my disk as .webloc files. From time to time I ssh into my Mac from a Linux box. Since .webloc files store the URL in a resource fork I can't do
% more bookmark.webloc
or a
% strings bookmark.webloc
because the data fork is empty. Is there any way to extract the URL in the command line?
|
|
•
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status:
Offline
|
|
cat someurl.webloc/rsrc dumps the binary, which includes the URL in plaintext. In general the resource fork is accessible by appending /rsrc.
It'll take a little fiddling in Perl to cleanly extract the URL itself, but it shouldn't be too hard.
|
|
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status:
Offline
|
|
Originally posted by Mithras:
cat someurl.webloc/rsrc dumps the binary, which includes the URL in plaintext. In general the resource fork is accessible by appending /rsrc.
It'll take a little fiddling in Perl to cleanly extract the URL itself, but it shouldn't be too hard.
Mithras, many thanks! I didn't know the trick with appending /rsrc to get the resource fork of the file
% strings bookmark.webloc/rsrc
prints the URL on the fourth line in clear text.
Great. Thanks! 
|
|
•
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status:
Offline
|
|
Sure. In the meantime I made this, although 'strings' will probably do you fine.
Code:
perl -ne '@ASCII = unpack("C*",$_); $in_url = 1; for($i=312; ($i < scalar @ASCII and $in_url == 1); $i++) {if ($ASCII[$i] == 0) { $in_url = 0; } else { print chr($ASCII[$i]); } }; print "\n";' < someurl.webloc/rsrc
Or, as a script that you can call with scriptname.pl someurl.webloc/rsrc:
Code:
#!/usr/bin/env perl
while (<>)
{
@ASCII = unpack("C*",$_);
$i = 312; # starting position
while ($i < scalar @ASCII and $ASCII[$i] != 0)
{
print chr($ASCII[$i]);
$i++;
}
print "\n";
}
(Last edited by Mithras; Feb 4, 2005 at 09:52 AM.
)
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |