PDA

View Full Version : accessing files


FEGator
07-10-2003, 06:56 AM
I wrote a perl/CGI program that opens a file and performs a search function, returning all entries that contain the specified word. I put it in the cgi-bin. I keep getting an error though that the file can't be opened. I used open(FH, "/filename") to access the files which I had put in the cgi-bin also. I was wondering where I need to put the files in order to access them or what the current directory is for programs located in the cgi-bin. If anyone could help out it would be greatly appreciated.

Thanks,
Stacy

bruce
07-10-2003, 10:38 AM
Can you post your code?

In general, Perl likes physical path. Look up your physical path in the control panel -> account information section


[b]quote:Originally posted by FEGator

I wrote a perl/CGI program that opens a file and performs a search function, returning all entries that contain the specified word. I put it in the cgi-bin. I keep getting an error though that the file can't be opened. I used open(FH, "/filename") to access the files which I had put in the cgi-bin also. I was wondering where I need to put the files in order to access them or what the current directory is for programs located in the cgi-bin. If anyone could help out it would be greatly appreciated.

Thanks,
Stacy
</blockquote id="quote"></font id="quote">

bruce
07-11-2003, 12:03 AM
that's probably it.

Try use the physical path, like e:\web\blah\blah\fefiles\Distribution.csv.txt.

You can find the exact path to your root in the account information section in the control panel.


[b]quote:Originally posted by FEGator

if($fileref == 0)
{
open(IFH, "/FEfiles/Distribution.csv.txt") || die "cannot open file: $! \n";
}
elsif($fileref == 1)
{
open(IFH, "/FEfiles/Contacts.csv.txt") || die "cannot open file: $! \n";
}

These are the open functions. The fileref is passed in from an HTML page. FEfiles is the directory that I have the files (comma delimited) in. The code just goes on to search the opened file. The error message I keep getting though is "cannot open file: no such file or directory"
</blockquote id="quote"></font id="quote">

FEGator
07-11-2003, 07:35 AM
if($fileref == 0)
{
open(IFH, "/FEfiles/Distribution.csv.txt") || die "cannot open file: $! \n";
}
elsif($fileref == 1)
{
open(IFH, "/FEfiles/Contacts.csv.txt") || die "cannot open file: $! \n";
}

These are the open functions. The fileref is passed in from an HTML page. FEfiles is the directory that I have the files (comma delimited) in. The code just goes on to search the opened file. The error message I keep getting though is "cannot open file: no such file or directory"

bruce
07-23-2003, 04:38 AM
try use \\ for


[b]quote:Originally posted by FEGator

OK I entered the physical path and now I am getting an error that reads:

Unrecognized escape \w passed through at E:\web\fieldengnet\htdocs\cgi-bin\FEprojecttest.cgi

There are other errors that read the same but for \h, \F, and \D. Are there restrictions that I need to specify, or what can I do to correct this?

Thanks.
</blockquote id="quote"></font id="quote">

FEGator
07-23-2003, 07:30 AM
OK I entered the physical path and now I am getting an error that reads:

Unrecognized escape \w passed through at E:\web\fieldengnet\htdocs\cgi-bin\FEprojecttest.cgi

There are other errors that read the same but for \h, \F, and \D. Are there restrictions that I need to specify, or what can I do to correct this?

Thanks.