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
Solved

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

Posted on 2003-11-05
6
204 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
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
perl script help 12 105
Shell script to bind my job to half the number of vCPUs in Solaris 8 121
stftime format 4 56
Edit Odbc.ini using perl module 2 90
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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 …
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…

839 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