Solved

Calling lynx from a perl script...

Posted on 1997-12-22
3
560 Views
Last Modified: 2012-06-27
I am trying to call the text browser lynx from inside a perl script using the -source option in order to grab the output (HTML code) and append it to a file... however, it just will not work when I call it from the web... it only works if I call it directly from the command line (if I have a one-line  script with almost exactly the same line.  I've tried changing permissions on the script, etc. to rwx by world and several variations of the call, but no to no avail.  Ideally, this will take a URL from a form via POST and then go grab the source code and keep it in a file.  Any ideas how I can implement this?  There must be a way without using sockets since a similar script works with an exact call when executed from the command line.  (Also, I'm using HP-UX).

The line is:

system "lynx $link -source >> megafile.spd\n";

where "$link" is a URL received from the POST method.


Thanks... Ryan
0
Comment
Question by:laze
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
alamo earned 100 total points
ID: 1209390
The first thing to check is that you are actually executing lynx - try checking whether system returns an error, and maybe the error will tell you something.

Also, it's possible that you need the full pathname for megafile.spd, what directory is current varies server to server.

Also- if taint checking is enabled on your system that might be the problem (I think that's the name for it, not certain). That system command using $link derived from a form is actually a dangerous practice unless you process it specially, since $link could be set by someone malicious to something like "|rm * |". There are ways around this, most easily by using the vector form  of system, but that doesn't allow for redirection or piping (which is why it's safe).

I had a similar problem, and decided to solve it by calling a shell script. (This was an easy decision since I had to run the script in question on both a Unix and a NT server, so this approach helped me more easily isolate the differences in calling lynx between the two systems.) You would use a system call similar to:

system("/home/mydir/calllynx.sh",$link) && die("system failed: $!");

and calllynx.sh would be:

/usr/local/bin/lynx -source  $1 >>/home/mydir/megafile.spd

One of the above approaches should solve your problem, good luck!
0
 

Author Comment

by:laze
ID: 1209391
Thank you, alamo... the second suggestion worked.  Thanks a bunch!  (threw in a few extra points for you)
0
 
LVL 6

Expert Comment

by:alamo
ID: 1209392
Thanks, and Happy Holidays!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl 101 11 72
How to strip .csv from file name 9 78
Linux rename files by reordering dates in the file name 6 33
perl: Cleaning meta tags using RegEX 12 64
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now