Sponsored Content
Homework and Emergencies Homework & Coursework Questions Perl CGI: No such file and directory: Yet file exists? Post 302931948 by jasondancks on Friday 16th of January 2015 11:36:11 PM
Old 01-17-2015
Perl CGI: No such file and directory: Yet file exists?

This technically a homework problem but I just need help solving this strange issue. The code is kinda long, I tried posted only the relevant parts.

1. The problem statement, all variables and given/known data:

I receive this error:

Code:
got error No such file or directory (2)

at:
Code:
open(GRADES,"<<$grades") or die "got error $! (".($!+0).")\n";

line 49 in CreateExam.pm called from submit.cgi, linked below.

2. Relevant commands, code, scripts, algorithms:
submit.cgi:
Code:
	my $check = CreateExam->new("/var/www/roger/homeworks/hw13/exam4.txt","/var/www/roger/homeworks/hw13/answers4.txt","/var/www/roger/homeworks/hw13/grades4.txt",$pathroot);


CreateExam.pm:

Code:
sub new {
	my ($class,$file,$answers,$grades,$script) = @_;
	#print "<p>in new: file: $file, grades: $grades</p>\n";
	return bless {'file'=>$file,'answers'=>$answers,'gradefile'=>$grades,'script'=>$script},$class;
}

Code:
my $grades = $self->{'gradefile'};
open(GRADES,"<<$grades") or die "got error $! (".($!+0).")\n";

3. The attempts at a solution (include all code and scripts):

I tried all of those recommendations: I remove any whitespace, I put in a check for any nonprintable characters, I hard-coded the path.

To make sure it wasn't a permissions issue, I installed suExec-custom for debian, all cgi scripts run under my UID, that didn't help.

I'm running this on debian with Apache

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

SUNY Polytechnic, Formerly SUNY Institute of Technology
100 Seymour Rd Utica NY 13502
CS 351 Web Development and Internet Programming
Scott Spetka scott@sunyit.edu
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Put header if file exists in a directory

Hi all, I will have to check a directory which is full of files. If any file more than 5 MB of space exists, write on it's head "Checked". Please help me. Thanks in advance! Deepak (5 Replies)
Discussion started by: naw_deepak
5 Replies

2. Shell Programming and Scripting

Copy contents of a directory only if a file exists

I'm looking to write a script that will check the contents of a directory, and if any files exist in that directory copy them to a temporary folder. The target files are only resident for a few seconds, so I think the script needs to be running constantly. Any pointers would be really... (3 Replies)
Discussion started by: danceofillusion
3 Replies

3. Shell Programming and Scripting

check if directory and file exists

cp $PATHLOGS/$DATE/*.* $TMP/logs_tmp/ cp $PATHLOGS/$DATE1/*.* $TMP/logs_tmp/ Before copying the files I have to check if the directory $DATE1 and $DATE2 exists. If directory exists then, check if the folder contains some files. if the file exists then, check if the file size is greater... (3 Replies)
Discussion started by: sandy1028
3 Replies

4. Shell Programming and Scripting

Checking whether the file exists under a directory and doing a diff

Hi Everyone, I am writing a shell script for the below needs and would like your suggestions and advices. I have a lot of scripting files(Shell Scripts) under the directory: /home/risk_dev/dev I have another directory which has a lot of shell scripts under the directory: ... (2 Replies)
Discussion started by: filter
2 Replies

5. Shell Programming and Scripting

How to check if a file exists in a directory?

I want to perform SQL *Loader operation only if a file named "load.txt" exists in a directory "/home/loc/etc". Please help how to check this with a if condition. (8 Replies)
Discussion started by: vel4ever
8 Replies

6. Shell Programming and Scripting

How to check if the file exists in directory?

Hi Gurus, I have a requests to find if all the file in the filelist exist in certain directory. example: my filelist abc def ddd cde afg how can I find these 5 files exists at director /home/abc Thanks in advance (7 Replies)
Discussion started by: ken6503
7 Replies

7. Shell Programming and Scripting

Not able to copy the file in perl cgi script

Hello experts, I am facing an very typical problem and hope the issue can be solved. I have a page download.cgi in /cgi-bin folder. use CGI; use CGI::Carp qw ( fatalsToBrowser ); use File::Copy copy("C:\\Program Files\\Apache Software... (8 Replies)
Discussion started by: scriptscript
8 Replies

8. Shell Programming and Scripting

Check whether file exists in directory

Hi guys, I am beginner trying to learn unix. So any help is welcomed. My requirement is to check whether is a file exists in a particular directory or not. The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
Discussion started by: maris_markur
1 Replies

9. UNIX for Beginners Questions & Answers

Check that at least one file exists in the directory.

There are some files with suffix dates like abc_20032019.dat abc_17032019.dat If at least one file exists then perform some operation else exit from execution. Korn shell ---------------------------------- array=($inputdir/abc*.dat) If ] ] then echo " file exits" else echo " file does... (10 Replies)
Discussion started by: Rajesh123
10 Replies

10. UNIX for Beginners Questions & Answers

If file pattern exists in directory then continue

he below looks in $dir for any pattern of fileone. As is, it executes but only returns File found if the exact format in the script exsists. Why isn't a pattern of fileone being looked for and if it is in $dir, File found. I think that is what should happen. Thank you :). dir=/path/to if... (5 Replies)
Discussion started by: cmccabe
5 Replies
AppConfig::CGI(3pm)					User Contributed Perl Documentation				       AppConfig::CGI(3pm)

NAME
AppConfig::CGI - Perl5 module for processing CGI script parameters. SYNOPSIS
use AppConfig::CGI; my $state = AppConfig::State->new(\%cfg); my $cgi = AppConfig::CGI->new($state); $cgi->parse($cgi_query); $cgi->parse(); # looks for CGI query in environment OVERVIEW
AppConfig::CGI is a Perl5 module which implements a CGI interface to AppConfig. It examines the QUERY_STRING environment variable, or a string passed explicitly by parameter, which represents the additional parameters passed to a CGI query. This is then used to update variable values in an AppConfig::State object accordingly. AppConfig::CGI is distributed as part of the AppConfig bundle. DESCRIPTION
USING THE AppConfig::CGI MODULE To import and use the AppConfig::CGI module the following line should appear in your Perl script: use AppConfig::CGI; AppConfig::CGI is used automatically if you use the AppConfig module and create an AppConfig::CGI object through the cgi() method. AppConfig::CGI is implemented using object-oriented methods. A new AppConfig::CGI object is created and initialised using the new() method. This returns a reference to a new AppConfig::CGI object. A reference to an AppConfig::State object should be passed in as the first parameter: my $state = AppConfig::State->new(); my $cgi = AppConfig::CGI->new($state); This will create and return a reference to a new AppConfig::CGI object. PARSING CGI QUERIES The "parse()" method is used to parse a CGI query which can be specified explicitly, or is automatically extracted from the "QUERY_STRING" CGI environment variable. This currently limits the module to only supporting the GET method. See AppConfig for information about using the AppConfig::CGI module via the cgi() method. AUTHOR
Andy Wardley, "<abw@wardley.org<gt"> COPYRIGHT
Copyright (C) 1997-2007 Andy Wardley. All Rights Reserved. Copyright (C) 1997,1998 Canon Research Centre Europe Ltd. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
AppConfig, AppConfig::State perl v5.12.4 2007-05-30 AppConfig::CGI(3pm)
All times are GMT -4. The time now is 07:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy