Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Checking to see if a paticular file exists

Reply
Thread Tools

Checking to see if a paticular file exists

 
 
vijay
Guest
Posts: n/a
 
      02-02-2004
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
 
Reply With Quote
 
 
 
 
Eric Schwartz
Guest
Posts: n/a
 
      02-02-2004
(vijay) writes:
> 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
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
 
Reply With Quote
 
 
 
 
Walter Roberson
Guest
Posts: n/a
 
      02-02-2004
In article < >,
vijay <> wrote:
: 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/...n/checkfile/hi there #wrong
http://www.yahoo.com/~vijaysenthilv/...ile/hi%20there #better
--
Live it up, rip it up, why so lazy?
Give it out, dish it out, let's go crazy, yeah!
-- Supertramp (The USENET Song)
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      02-02-2004
vijay <> wrote:

> 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.


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      02-03-2004
vijay wrote:
> 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


 
Reply With Quote
 
vijay
Guest
Posts: n/a
 
      02-03-2004
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
 
Reply With Quote
 
Brad Baxter
Guest
Posts: n/a
 
      02-03-2004
On Tue, 3 Feb 2004, vijay wrote:
> 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
 
Reply With Quote
 
gnari
Guest
Posts: n/a
 
      02-03-2004
"vijay" <> wrote in message
news: om...

> 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



 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      02-04-2004
On Tue, 03 Feb 2004 11:46:13 -0800, vijay wrote:

> 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.

 
Reply With Quote
 
vijay
Guest
Posts: n/a
 
      02-04-2004
"gnari" <> wrote in message news:<bvp1ni$14i$>...
> "vijay" <> wrote in message
> news: om...
>
> > 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 ?

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

>
> gnari

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking to see if a property exists within an object. Daz Javascript 3 05-04-2007 06:43 PM
How is it that i cannot search for a paticular website but everyone i know can? wendyuk Computer Support 7 09-28-2006 02:45 PM
checking to see if DDL value exists Darrel ASP .Net 4 12-10-2004 03:23 PM
Checking to see if a cookie exists CES ASP .Net 2 02-13-2004 04:41 AM
Checking to see if request.getParameter("myparam") exists Steveo Java 2 09-17-2003 10:44 PM



Advertisments