I cannot get my script to save new files.
The path is correct. Another script uses /home/hampton1/data dir for writing out student.dat and it works fine.
The open<SDATA> statement is ok - I can see the data after stuffing it into an array.
However, no matter what I do, the new files are not being saved.
#!/usr/bin/perl
use CGI;
use File::Copy;
use warnings;
# define names of student reg info file,student count file and name of
+ js file to be sritten out
$sdata="/home/hampton1/data/student.dat";
$scnt="/home/hampton1/data//student_count.dat";
$jscd="/home/hampton1/data/jscd.js";
# open existing student reg file
open(SDATA,"$sdata")|| die("Could not open file: $!\n");
# Put file into array
@line = <SDATA>;
print @line;
# confirms array contains contents of file
close SDATA;
# delete existing count & js file - so they can be to be recreated
# test code
unlink($scnt);
unlink($jscd);
# create file(> symbol is overwriting)
open (SCNT,">$scnt");
close SCNT;
# set all permissions
chmod 0777, $scnt or die "Couldn't chmod $scnt: $!";
# create file(> symbol is overwriting)
open (JSCD,">$jscd");
# print results to javascript file
print JSCD "This is a test ()\n";
close JSCD;
# set all permissions
chmod 0777, $jscd or die "Couldn't chmod $jscd: $!";
I deleted all the processing code to see if it would simply create and save after I uploaded it.
the script works correctly on my PC with the files in the root dir and when they are in a subdir.
I made sure to upload in ASCII and set all permissions.
what am I overlooking?
Any help will be appreciated.
JV
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.