Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update a file

Status
Not open for further replies.

ozi403

Technical User
Joined
Apr 29, 2002
Messages
54
Location
TR
Hi,

I try to update a file from web browser.Like that:

#!/usr/local/bin/perl

print "</body></html>";
print "Content-type: text/html\n\n";
print "<html>\n";
print "<body>\n";

@ry = `rsh bcksrv7 mminfo -a|head -10`;

open (OUTFILE,">ozan");
print OUTFILE "@ry \n";
close (OUTFILE);

print "</body></html>";
exit;

But when I run from it doesn't update the file "ozan". I try from server side (Solaris 9) at the command prompt, it works.

What is going wrong with my script?
Help!
 
Is the ozan file inside the same directory that your Perl script is running from? If not, you'll either need to have the script change directories to the correct one (chdir command) or put in the absolute path to the file you want to update.

Another thing to check for is that @ry is actually being populated with information. Since yu're doing this through, what looks like a web browser, print the array to the screen to make sure something's being populated there.

Code:
print "<pre>@ry</pre>\n";

- Rieekan
 
This is almost certainly a permissions problem of some kind.
You need to find out what userid the script will run as when run from the server.
Possibly Apache and possibly nobody.
When you run the script server side, you're logging in as a used that DOES have permission to write the file.

Maybe you can find out what permissions you have by getting the script to create the file in /tmp (where it should be possible for anyone to write) and then you can check the userid of the file to see what it was written as.

Trojan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top