Solved

Calling lynx from a perl script...

Posted on 1997-12-22
3
585 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Six Sigma Control Plans

717 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