Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calling lynx from a perl script...

Posted on 1997-12-22
3
Medium Priority
?
606 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 400 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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

610 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