file path & windows cgi

Scott Griffitts scott at griffitts.com
Fri Sep 28 10:06:12 EDT 2001


"Steve Holden" <sholden at holdenweb.com> wrote in message news:<7iLs7.16893$7k.461150 at atlpnn01.usenetserver.com>...
> "Scott Griffitts" <scott at griffitts.com> wrote ...
> > Trying to read a file, this script works for me:
> >
> > z = open('I:\\test\\test.txt')
> > for x in z.readlines():
> >     b = "%s%s" % (b,x)
> > z.close()
> > print b
> >
> > But if I try and get the path to the file via an html form:
> >
> > import cgi
> > y = cgi.FieldStorage()
> > z = open(y['getter'].value)
> > for x in z.readlines():
> >     b = "%s%s" % (b,x)
> > z.close()
> > print b
> >
> > I get:
> >
> > Traceback (most recent call last):
> >   File "c:\inetpub\wwwroot\python\brow2.py", line 5, in ?
> >     z = open(y['getter'].value)
> > IOError: [Errno 22] Invalid argument: 'I:\\test\\test.txt'
> >
> > Does anyone know what I'm missing here?  Thanks.
> 
> When you run the test you are working on one environemnt, but it may be that
> the same shares are not available to the web server. You don't say which web
> server you are using, but certainly with IIS I've seen that shares are not
> always available. I don't remeber the exact reasons, but would first of all
> suggest you try accessing a file on a drive you KNOW is available (such as
> C:) and then working forwards from there.
> 
> Clearly open() isn't seeing the file, and just as clearly it's reporting the
> right path, so maybe its the server environment.
> 
> regards
>  Steve

Thanks, that should have been obvious to me but I guess the 'invalid
argument' wording kept throwing me off.

-Scott



More information about the Python-list mailing list