473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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.
Oct 17 '08 #1
6 4628
On Fri, Oct 17, 2008 at 10:07 AM, Robocop <bt*****@physics.ucsd.eduwrote:
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
Oct 17 '08 #2

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
Oct 17 '08 #3
On Oct 17, 10:27*am, "Chris Rebert" <creb...@ucsd.eduwrote:
On Fri, Oct 17, 2008 at 10:07 AM, Robocop <btha...@physics.ucsd.eduwrote:
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
Oct 17 '08 #4
On Oct 17, 10:27*am, "Chris Rebert" <creb...@ucsd.eduwrote:
On Fri, Oct 17, 2008 at 10:07 AM, Robocop <btha...@physics.ucsd.eduwrote:
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")
Oct 17 '08 #5
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.
You can get the directory of the script with this useful snipplet:

import os
HERE = os.path.dirname(os.path.dirname(__file__))
PS_FILE = os.path.join(HERE, "base.ps")

Christian

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Preston Crawford | last post by:
I'm looking to quickly get a photo album online. Very simple, thumbnails, a few pages, maybe a description, but hopefully a small script that's easy to edit and work into my existing site. I know...
7
by: Lowell Kirsh | last post by:
I have a script which I use to find all duplicates of files within a given directory and all its subdirectories. It seems like it's longer than it needs to be but I can't figure out how to shorten...
3
by: comp.lang.php | last post by:
Using Linux/PHP 4.3.2 CLI: $fileID = fopen('myfile.txt', 'r'); // WORKS JUST FINE Using Linux/PHP 4.3.8 CLI: $fileID = fopen('myfile.txt'); // THROWS WARNING 'no such file or directory...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
9
by: Daz | last post by:
Hi everyone. I am a little stumped at why when I try to include a file in same directory as the script being processed, it looks in the same directory as the script that included it to begin...
4
cassbiz
by: cassbiz | last post by:
Could use some help here. This script is carrying over an image just fine but the text isn't coming over. can you see why it is not working???? from the form I want to carry over two lines of...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
7
by: jeddiki | last post by:
Hi, As I am in Turkey at present, I can not see vidoes on youtube. So I have tried a few proxies but keep finding them slow or not working. So I have installed myphpProxy on my server under...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.