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

Discussion in 'Python' started by Robocop, Oct 17, 2008.

  1. Robocop

    Robocop Guest

    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.
     
    Robocop, Oct 17, 2008
    #1
    1. Advertising

  2. Robocop

    Chris Rebert Guest

    On Fri, Oct 17, 2008 at 10:07 AM, Robocop <> wrote:
    > 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.
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
     
    Chris Rebert, Oct 17, 2008
    #2
    1. Advertising

  3. On Oct 17, 2008, at 1:07 PM, Robocop wrote:

    > 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
     
    Philip Semanchuk, Oct 17, 2008
    #3
  4. Robocop

    Robocop Guest

    On Oct 17, 10:27 am, "Chris Rebert" <> wrote:
    > On Fri, Oct 17, 2008 at 10:07 AM, Robocop <> wrote:
    > > 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.
    > > --
    > >http://mail.python.org/mailman/listinfo/python-list

    >
    >


    The output is /home/bruce/DEVadhc/attendance

    which is the directory i expected, and the directory that contains
    base.ps
     
    Robocop, Oct 17, 2008
    #4
  5. Robocop

    Robocop Guest

    On Oct 17, 10:27 am, "Chris Rebert" <> wrote:
    > On Fri, Oct 17, 2008 at 10:07 AM, Robocop <> wrote:
    > > 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.
    > > --
    > >http://mail.python.org/mailman/listinfo/python-list

    >
    >



    Also i forgot this pertinent line: output = open("/home/bruce/attend/
    media/ps/barcodes.ps", "w")
     
    Robocop, Oct 17, 2008
    #5
  6. Robocop

    Robocop Guest

    I'm kind of an idiot, i just realized the problem. Sorry for wasting
    your time, and thanks for the help!
     
    Robocop, Oct 17, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWFyayBQYXJ0ZXI=?=

    Form still being submitted despite being invalid

    =?Utf-8?B?TWFyayBQYXJ0ZXI=?=, Jul 25, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    621
  2. Krick
    Replies:
    1
    Views:
    1,487
    John C. Bollinger
    Aug 15, 2003
  3. Asfand Yar Qazi
    Replies:
    3
    Views:
    309
    Bill Seurer
    May 10, 2004
  4. Replies:
    5
    Views:
    391
  5. Replies:
    15
    Views:
    1,266
    Harlan Messinger
    Mar 20, 2008
Loading...

Share This Page