devries Posted December 30, 2004 Report Share Posted December 30, 2004 Can somone translate this perl script #!/usr/bin/perl use strict; use warnings; our $url = 'http://www.foksuk.nl'; our $prefix = 'http://www.foksuk.nl/'; our $attr_value = '0'; our $attr_name = 'border'; our $regex = 'd\d+\.(gif|jpg)$'; $0=~m|^(.*/).*?$|; require $1.'komics.pm'; into a bash script. As far as I can see the script works fine. I get the correct URL but when I run it from komics (it should fetch a comic) instead of an gif file I get an php file. I had the same (sort of) problem with an earlier perl script from Papaschtroumpf (http://mandrakeusers.org/index.php?showtopic=21696) but the bash script from Aru works very well. Quote Link to comment Share on other sites More sharing options...
aru Posted December 30, 2004 Report Share Posted December 30, 2004 Here you are (as bonus I put some code to retrieve and show you the comic strip w/o Komics ;) btw it is better to use not such restrictive regexps for such easy tasks. Also your regexp: d\d+\.(gif|jpg)$ ends with a dollar sign that matches end of line when the image in that web page is not on an end of line (I may be wrong because I have a very limited knowledge of perl regexps. here is the script #! /bin/bash regexp='.*\(imggif.php?i=/upload/d[0-9]\{1,4\}.gif\).*' main_url="http://www.foksuk.nl/" img_url=$(wget -qO - $main_url | sed -n "s@$regexp@$main_url\1@p") echo -n "${img_url}" # outputs todays image name # BONUS! ---------------------------------------- # this part allows you to see the strip right now, # remove if you just want the img url: imgname=Cartoon_van_de_dag.gif echo wget -qO $imgname "$img_url" eog $imgname HTH Quote Link to comment Share on other sites More sharing options...
devries Posted December 30, 2004 Author Report Share Posted December 30, 2004 Thanks for your help. The script works fine, only just as fine as the perl script. :( Komics is naming the file komics1aFwAeb.php (the bit before php changes of course). Kuickshow won't show php files and kview only when it's not the 'designated' apllication to open the file. But I can let komics save it and than it just opens fine in kview. http://www.foksuk.nl/imggif.php?i=/upload/d686.gif Is the complete url. I'm guessing komics cuts of (after the download) at imggig.php. I've no idea what files are involved so we'll have to wait for the next bug fix. :) Thanks again for your help Quote Link to comment Share on other sites More sharing options...
aru Posted December 30, 2004 Report Share Posted December 30, 2004 I've no idea what files are involved so we'll have to wait for the next bug fix. :) mean while you can hack a little bit my script and lie komics telling it that the url is the downloaded comic strip ;) for example: #! /bin/bash regexp='.*\(imggif.php?i=/upload/d[0-9]\{1,4\}.gif\).*' main_url="http://www.foksuk.nl/" img_url=$(wget -qO - $main_url | sed -n "s@$regexp@$main_url\1@p") imgname=~/Cartoon_van_de_dag.gif wget -qO $imgname "$img_url" echo -n "$imgname" # outputs the path to the comic image, that will be enough for comics Quote Link to comment Share on other sites More sharing options...
devries Posted December 30, 2004 Author Report Share Posted December 30, 2004 Who needs a bugfix when we have you :D. Must be nice to be so good. Thanks again. :D Quote Link to comment Share on other sites More sharing options...
aru Posted December 31, 2004 Report Share Posted December 31, 2004 Thanks! That's a good feedback, isn't it? Seriously I'm not that good, and this time was just a matter of simple logic... but is always nice to read shuch things form time to time Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted January 3, 2005 Report Share Posted January 3, 2005 /* must. stop. myself. from. commenting. on. that. one. */ ciao! Quote Link to comment Share on other sites More sharing options...
aru Posted January 3, 2005 Report Share Posted January 3, 2005 /* must. stop. myself. from. commenting. on. that. one. */ ciao! <{POST_SNAPBACK}> against what my blood is requesting me, I will avoid answering your post too my friend Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.