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

x
?
Solved

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

Posted on 2003-11-05
6
Medium Priority
?
231 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 100 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 100 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

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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

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