Script can't find input file despite being in the same directory

R

Robocop

I have a simple little script that reads in postscript code, appends
it, then writes it to a new postscript file. Everything worked fine a
month ago, but after rearranging my directory tree a bit my script
fails to find the base postscript file.

The line in question is:

for line in fileinput.input(['base.ps']):
output.write(line)

I'm kind of at a loss as the script is executing in the same directory
as base.ps, yet it can't find it. I'm relatively new to python
scripting, so i'm expecting it's just something i haven't learned
about python that is causing the problem. Any suggestions would be
greatly appreciated.
 
C

Chris Rebert

I have a simple little script that reads in postscript code, appends
it, then writes it to a new postscript file. Everything worked fine a
month ago, but after rearranging my directory tree a bit my script
fails to find the base postscript file.

The line in question is:

for line in fileinput.input(['base.ps']):
output.write(line)

What directory is output if you insert the lines:

from os import getcwd
print "CWD:", getcwd()

just before the line is question?

Cheers,
Chris
 
P

Philip Semanchuk

I have a simple little script that reads in postscript code, appends
it, then writes it to a new postscript file. Everything worked fine a
month ago, but after rearranging my directory tree a bit my script
fails to find the base postscript file.

The line in question is:

for line in fileinput.input(['base.ps']):
output.write(line)

I'm kind of at a loss as the script is executing in the same directory
as base.ps, yet it can't find it. I'm relatively new to python
scripting, so i'm expecting it's just something i haven't learned
about python that is causing the problem. Any suggestions would be
greatly appreciated.

Put this before the line that fails and see what it tells you:
print os.getcwd()


getcwd = get current working directory
 
R

Robocop

I have a simple little script that reads in postscript code, appends
it, then writes it to a new postscript file.  Everything worked fine a
month ago, but after rearranging my directory tree a bit my script
fails to find the base postscript file.
The line in question is:
 for line in fileinput.input(['base.ps']):
   output.write(line)

What directory is output if you insert the lines:

from os import getcwd
print "CWD:", getcwd()

just before the line is question?

Cheers,
Chris
--
Follow the path of the Iguana...http://rebertia.com


I'm kind of at a loss as the script is executing in the same directory
as base.ps, yet it can't find it.  I'm relatively new to python
scripting, so i'm expecting it's just something i haven't learned
about python that is causing the problem.  Any suggestions would be
greatly appreciated.

The output is /home/bruce/DEVadhc/attendance

which is the directory i expected, and the directory that contains
base.ps
 
R

Robocop

I have a simple little script that reads in postscript code, appends
it, then writes it to a new postscript file.  Everything worked fine a
month ago, but after rearranging my directory tree a bit my script
fails to find the base postscript file.
The line in question is:
 for line in fileinput.input(['base.ps']):
   output.write(line)

What directory is output if you insert the lines:

from os import getcwd
print "CWD:", getcwd()

just before the line is question?

Cheers,
Chris
--
Follow the path of the Iguana...http://rebertia.com


I'm kind of at a loss as the script is executing in the same directory
as base.ps, yet it can't find it.  I'm relatively new to python
scripting, so i'm expecting it's just something i haven't learned
about python that is causing the problem.  Any suggestions would be
greatly appreciated.


Also i forgot this pertinent line: output = open("/home/bruce/attend/
media/ps/barcodes.ps", "w")
 
R

Robocop

I'm kind of an idiot, i just realized the problem. Sorry for wasting
your time, and thanks for the help!
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top