Reputation: 3582
I have perl code, which get some date from database and prints it to a file.
------------------------
$select_month = $FORM{month};
------------------
print qq~<form method="post">
<select name="month">
<option value='01'>JAN</option>
-------
<option value='12'Dec'>DEC</option>
</select>
<INPUT type="submit" value="Go">
</form>
~;
print $select_month;
my $file_name_dates = "0N3_CUS_".$select_month."csv";
open (my $FH, "+>", $file_name_dates);
my $dbh = &connect_oracle;
my $Select = $dbh->prepare($sql_1);
$Select->execute($select_month,$select_year,$select_month,$select_year);
The thing is that
print $select_month;
works, and it prints month to my html. But file isn't created. What's the problem? File opening works when I run my script from command line.
Upvotes: 1
Views: 362
Reputation: 17946
The current working directory for your script is likely different than what you expect when running from a webserver. Try changing your filename to a full path rather than a relative path. For example:
my $base_path = "/path/to/files/";
my $file_name_dates = $base_path . "0N3_CUS_".$select_month."csv";
Even if the full pathname is correct, your userid may be something deprivileged, such as nobody
. If using a full path does not work, point to a directory that any user can write to and that any user can reach to ensure userid is not the issue.
Upvotes: 1