Checking to see if a paticular file exists

V

vijay

Hi
I'm trying to check to see if a paticular file exist on the machine,
i'm unable to check for files insides directories which have space in
between their names, If i run the script from the command prompt they
seem to run fine, but when i try to open the script on a browser, it
is not able to even open the directory, i get a Invalid Argument
Error,This does not happen for directories which do not have a space
in their name.Any help is greatly appreciated
Sincerly
Vijay
 
E

Eric Schwartz

I'm trying to check to see if a paticular file exist on the machine,
i'm unable to check for files insides directories which have space in
between their names, If i run the script from the command prompt they
seem to run fine, but when i try to open the script on a browser, it
is not able to even open the directory, i get a Invalid Argument
Error

perldoc -q 500

<wavy lines>
use PSI::ESP;

print <<EOGUESS;

I bet you're not using CGI.pm, and you're not decoding URI-encoded
entities properly. After you've followed all the directions in the
FAQ I just referred you to, try creating a small CGI program, using
CGI.pm, that just prints out "It exists", or "It doesn't exist" when
you pass a filename as a parameter. It shouldn't take more than 10
lines. Doing this will probably help you debug your problem.

EOGUESS
__END__
</wavy lines>


-=Eric
 
W

Walter Roberson

: I'm trying to check to see if a paticular file exist on the machine,
:i'm unable to check for files insides directories which have space in
:between their names, If i run the script from the command prompt they
:seem to run fine, but when i try to open the script on a browser, it
:is not able to even open the directory, i get a Invalid Argument
:Error,This does not happen for directories which do not have a space
:in their name.Any help is greatly appreciated

How are you passing the directory name in to the CGI script? If you
are passing it through the GET method (i.e, the directory name
is part of the URL) then make sure that you replace each space
with the character triple %20 -- .e.g,

http://www.yahoo.com/~vijaysenthilv/cgi-bin/checkfile/hi there #wrong
http://www.yahoo.com/~vijaysenthilv/cgi-bin/checkfile/hi there #better
 
T

Tad McClellan

vijay said:
I'm trying to check to see if a paticular file exist on the machine,


Show us your code that is trying to check to see if a paticular file
exist on the machine, and we will help you fix it.

If i run the script from the command prompt they
seem to run fine, but when i try to open the script on a browser, it ^^^^^^^
is not able to even open the directory, i get a Invalid Argument

perldoc -q browser

My CGI script runs from the command line but not the browser. (500
Server Error)

Any help is greatly appreciated


Any code is greatly appreciated.
 
J

Jürgen Exner

vijay said:
I'm trying to check to see if a paticular file exist on the machine,

See "perldoc -f -e"
i'm unable to check for files insides directories which have space in
between their names, If i run the script from the command prompt they
seem to run fine,

Then chances are your problem is _not_ a Perl problem. Please see
"perldoc -q 500"
but when i try to open the script on a browser,

How do you "open a script on a browser"?
it
is not able to even open the directory, i get a Invalid Argument
Error,
This does not happen for directories which do not have a space
in their name.Any help is greatly appreciated

Well, quite impoossible to do without seeing your code (or actually a
minimal example that exposes the problem).

jue
 
V

vijay

Hi
I'm sorry i should have posted the code
__________________________________________________
require "cgi-lib.pl";
print "Content-type: text/html\n\n";



if (!(-e 'J:\DWGS\parking\LOT-10.dwg')) {
print "Not working----"
}

else {
print "working---";
}



if (!(-e 'J:\DWGS\Project Archive\911-001-1922-A-002-AB.pdf')) {
print "Not working----"
}

else {
print "working---";
}
____________________________________________________________________


The above code prints working and working when i run it from the DOS
promt but prints working and Not working when i open it in a browser,
i Did try using the %20 and forward slash format but that didnt help
either


Thanks
Sincerly vijay
 
B

Brad Baxter

The above code prints working and working when i run it from the DOS
promt but prints working and Not working when i open it in a browser,
i Did try using the %20 and forward slash format but that didnt help
either

I suspect your question is a variation of this faq:

My CGI script runs from the command line but not the browser.

That is, I think you have a CGI question rather than a Perl question.

Regards,

Brad
 
G

gnari

require "cgi-lib.pl";
print "Content-type: text/html\n\n";

I am not going to mention strict, warnings and CGI.pm now,
but I might next time.
...
if (!(-e 'J:\DWGS\parking\LOT-10.dwg')) {
...
if (!(-e 'J:\DWGS\Project Archive\911-001-1922-A-002-AB.pdf')) {
...
i Did try using the %20 and forward slash format but that didnt help
either

the %20 does not apply in your case.

does the problem go away if you rename away the space ?
does the first filepath fail if you rename a space into it?

maybe it is a permission problem. the user executing the script
as cgi is not the same as the one in the shell. and their environments
differ as well.

gnari
 
J

James Willmore

Hi
I'm sorry i should have posted the code
__________________________________________________
require "cgi-lib.pl";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Please tell me this is something *you* wrote and not the old Perl4 CGI
library ......

If it's the latter, *please* consider using the CGI module .....

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
"We are upping our standards ... so up yours." -- Pat Paulsen
<for President, 1988.
 
V

vijay

gnari said:
I am not going to mention strict, warnings and CGI.pm now,
but I might next time.


the %20 does not apply in your case.

does the problem go away if you rename away the space ?
Yes it does go away
does the first filepath fail if you rename a space into it? Yes it fails

maybe it is a permission problem. the user executing the script
as cgi is not the same as the one in the shell. and their environments
differ as well.

I get a invalid Argument error when i try to opendir command on
directories with space in their file name.I guess its a CGI error than
something to deal with perl, i'll try searching CGI sites to see if i
can come up with a fix
Thanks
Vijay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top