473,396 Members | 1,748 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,396 software developers and data experts.

Help with Python

Hello!



I am new to Python and I would like to write the following code:



I need to check for a directory and move it to other directory if is
found. The directory always starts with outlog.XYZ and ends in XYZ
(where XYZ are variables). I need to use wild characters. Here is what
I have, but is not working. Any help would be appreciated.



#Path for the file

home_trace = "/home/testeng/ca/tds/outlog.* "



#Path for the directory where I want to move the file

directory = "/home/testeng/ca/tds/unattached"



#If statement

if os.path.exists(home_trace):

os.system ("chmod -fR 775 outlog.* ")

os.system ("mv outlog.* " + directory)



Fernando Armenta


Jul 18 '05 #1
1 1765
On Tue, 16 Sep 2003 14:16:56 -0700, rumours say that "Fernando Armenta"
<fa******@pillardata.com> might have written:
I need to check for a directory and move it to other directory if is
found. The directory always starts with outlog.XYZ and ends in XYZ
(where XYZ are variables). I need to use wild characters. Here is what
I have, but is not working. Any help would be appreciated.

#Path for the file

home_trace = "/home/testeng/ca/tds/outlog.* "

#Path for the directory where I want to move the file

directory = "/home/testeng/ca/tds/unattached"

#If statement

if os.path.exists(home_trace):

os.system ("chmod -fR 775 outlog.* ")

os.system ("mv outlog.* " + directory)


Import glob, then for each file in glob.glob('outlog.*'), use os.chmod()
and os.rename() with appropriate parameters. os.rename() would probably
fail if you moved your files to another filesystem, but in your example
this does not seem to be the case.

PS I just remembered that I have seen at least one C++ freshly-graduated
programmer serving as a sysadm in a university praising C++ as a
scripting language (!); his code was full of system() calls. When I
asked him, "why not a shell script?", he said "this is faster... it's
C++...".
I mentioned the difference of a shell doing spawn() and an executable
doing spawn() to a shell doing another spawn().
Discussing it further, he said that executables are not "legible"; so,
*just before* suggesting a "chmod 500" operation on a root-owned script,
I told him about the "strings" command as an obvious counter-argument
for a naive disassembly. I chose the wrong order of sentences; he
actually removed /usr/bin/strings in haste, as if his job was depending
on its disappearance... FWIW, it did --in the opposite way.
There are no limits.
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
Jul 18 '05 #2

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

Similar topics

4
by: Guido van Rossum | last post by:
I'm pleased to announce that the Python Software Foundation (PSF) is now accepting donations from individuals and companies interested in supporting our mission to improve the Python programming...
10
by: Jacek Generowicz | last post by:
Where can I find concise, clear documentation describing what one has to do in order to enable Python's internal help to be able to provide descriptions of Python keywords ? I am in a situation...
0
by: python-help-bounces | last post by:
Your message for python-help@python.org, the Python programming language assistance line, has been received and is being delivered. This automated response is sent to those of you new to...
3
by: stuart_white_ | last post by:
I've just upgraded from Python 2.3.3 to Python 2.4.2, and, although the new version of Python seems to be running correctly, I can't seem access the help from the interpreter. On Python 2.3.3...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
1
by: Paul Rubin | last post by:
In Windows if you click the Help dropdown, IDLE launches a help window as it should. The help contents are included in the installation. In Linux, clicking Help launches a web browser, which is...
0
by: Jack Wu | last post by:
Hi I've spent a good majority of my day trying to figure out how to have PIL 1.1.5 working on my OSX 10.3.9_PPC machine. I'm still stuck and I have not gotten anywhere. Could somebody please...
2
by: Scott Smith | last post by:
To all you vi/vim users out there..... I am just getting into python and am trying to learn how to use the python.vim script. I really like the fact that it autoindents for me while inserting...
0
by: Support Desk | last post by:
That’s it exactly..thx -----Original Message----- From: Reedick, Andrew Sent: Tuesday, June 03, 2008 9:26 AM To: Support Desk Subject: RE: regex help The regex will now skip anything with...
0
by: Ahmed, Shakir | last post by:
Thanks everyone who tried to help me to parse incoming email from an exchange server: Now, I am getting following error; I am not sure where I am doing wrong. I appreciate any help how to resolve...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.