Solved

Can't run a script called from a HTML Page but can from the Command Line

Posted on 2003-11-05
6
220 Views
Last Modified: 2010-03-04
I have a simple script that opens a file and concatenates a line of text to the end of the file before closing it again. The script works fine when used from the command line on my PC. But when I call the file form an HTML Page the script dosn't work - nothing gets written to the file.

HTML Code (addNewsItem.html):
================================================
<FORM ACTION="scripts/addNewsItem.pl" METHOD="POST">
.
.
.
</FORM>


Perl Code (addNeswItem.pl):
================================================
#!/usr/bin/perl -w
use CGI::Carp "fatalsToBrowser";

$string="Today there was a car crash on the I5";

$outputFile="newsHeading.js";
open(OUTPUT,">>$outputFile") || die("Cannot Open File");
print OUTPUT "$string";            
close(OUTPUT);


There is more in both files but I guess this is the bones of the source....

Any help,
- Troy
0
Comment
Question by:Troyh
[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
6 Comments
 
LVL 20

Accepted Solution

by:
jmcg earned 25 total points
ID: 9691664
A script run from the command line runs with your permissions.

A script run under the web server typically runs with the permissions of the user 'nobody'. On most systems, 'nobody' does not have permission to create files or write on files just anywhere.

Your script appears to be properly written to send notice of this error back to you. Does it? Or does it fail to complain, too?
0
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9691668
Is newsHeading.js is same path with your perl script?

~ fantasy ~
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 25 total points
ID: 9691773
Never use relative paths in CGI scripts.  You can *never* guarantee your current working directory.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9696974
why not simply check the server logs, error log in particular?
think that Tintin is very close to the first mistake ..
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10049577
Nothing has happened on this question in more than 8 weeks. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
split points between jmcg and Tintin.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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

695 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