473,606 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to move up a directory...sil ly question

Sorry, but how does one move up a directory ?

I'm in a directory from which I called a script. Part of the script
functionality is checking the permissions of the directory I am in. I may
need to change the directory permissions depending on what they are. Hence,
I need to be able to move up [and possibly down] one level of the directory
tree.

chdir? Something like cd .. would be nice

Thank you.
Jul 19 '05 #1
2 16750

I'm not sure if the Perl chdir() function accepts a ".." argument. If it
does, you can do:

chdir("..");

to go up a directory. If not, you will have to do something such as:

$currdir = `pwd`; chomp $currdir; # gets current directory
$currdir =~ s/ \/[^\/]+$//; # removes the last / and everything after it
chdir($currdir) ;

That's a very crude example where I'm not doing things like checking return
values or making sure we are not already in the root directory. However,
that's the general idea.
"John" <no**@none.co m> wrote in message
news:81******** *************@n ews-server.bigpond. net.au...
Sorry, but how does one move up a directory ?

I'm in a directory from which I called a script. Part of the script
functionality is checking the permissions of the directory I am in. I may
need to change the directory permissions depending on what they are. Hence, I need to be able to move up [and possibly down] one level of the directory tree.

chdir? Something like cd .. would be nice

Thank you.

Jul 19 '05 #2

"Kris Wempa" <calmincents(NO _SPAM)@yahoo.co m> wrote in message
news:bk******** *@kcweb01.netne ws.att.com...

I'm not sure if the Perl chdir() function accepts a ".." argument. If it
does, you can do:

chdir("..");

to go up a directory. If not, you will have to do something such as:

$currdir = `pwd`; chomp $currdir; # gets current directory
$currdir =~ s/ \/[^\/]+$//; # removes the last / and everything after it
chdir($currdir) ;

That's a very crude example where I'm not doing things like checking return values or making sure we are not already in the root directory. However,
that's the general idea.
"John" <no**@none.co m> wrote in message
news:81******** *************@n ews-server.bigpond. net.au...
Sorry, but how does one move up a directory ?

I'm in a directory from which I called a script. Part of the script
functionality is checking the permissions of the directory I am in. I may need to change the directory permissions depending on what they are.

Hence,
I need to be able to move up [and possibly down] one level of the

directory
tree.

chdir? Something like cd .. would be nice

Thank you.


Great! Thanks very much Kris.
Jul 19 '05 #3

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

Similar topics

9
5322
by: FISH | last post by:
Ever have one of those days when you're not sure if it's you who's gone mad, or the rest of the world? I have an Open Source project on SourceForge for communication with YSMG - Yahoo's IM protocol. I keep the project source in three directories, based upon the code's function: one for the network API code itself, one for the support APIs (basic chat spam filtering, Swing models, rich text decoders, etc), and one for the test client...
2
2880
by: Neil S. | last post by:
I'm a bit of a newbie to C++, so I apologize in advance if this is silly. I've found many examples of binding to AD with ADsOpenObject or IADsOpenDsObject. I can't compile my code. I've tried including every header that would be appropriate. I always get "error LNK2020: unresolved token(0A0000C1)IID_IADsOpenDSObject" or whatever other IID* value I pass in as the second param to the function. I've also tried the ADsOpenObject...
3
8835
by: andrew | last post by:
I do not understand how this function should work. It seems to be different than when I drag a folder ... error message: Cannot create a file when that file already exists. c:\atest has subfolder btest which has subfolder ctest plus a single file. ( c:\atest\btest\ctest\test.txt ) c:\aatest is an empty folder. If I drag atest to aatest, I will have c:\aatest\atest\btest\ctest\test.txt But as noted using the function as below wont...
1
4069
by: rv | last post by:
I am developing an ASP.NET website with C#, VS 2003 and Framework 1.1. For some reason every time I execute a Directory.Move command, the next command takes 10-20 seconds to execute. Has anyone else experienced this? I just want to rename a directory, so if there is a better way I am all ears. Thanks
1
3044
by: Matthew Eno | last post by:
I have a problem where I'm developing some code that moves files from one place to another (on the same drive) with the destination file having a new name. What's happening is that the line of code where I do the file.move is taking a very long time (in the order of around 7 seconds for a simple 30kb file). The only thing that I can think may be causing the problem is that theere is around 1.1 million files to move, so perhaps it's the
2
4431
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist then skip this file and move onto the next file (line). If file is there then move to a sirectory. Here is the code I have (Feel free to make corrections as needed. If possible make changes in red)
3
3273
by: Arpan | last post by:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls. Using the FileUpload control, I want to give users the provision to move & delete files that DO NOT exist in C:\Inetpub\wwwroot (i.e. the root directory). This is the code: <script runat="server"> Sub MoveFile(ByVal obj As Object, ByVal ea As EventArgs) File.Move(fudFileSource.FileName, txtFileDest.Text) 'File.Move("F:\4.jpg", "C:\4.jpg") End Sub
12
2997
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed the instructions and couldnt get the correct results. heres the code stuff... temperature=input("what is the temperature of the spam?") if temperature>50: print "the salad is properly cooked." else:
22
1979
by: Ramon F Herrera | last post by:
My goal is to study (in the RMS sense) and familiarize myself with some OSS code, until I reach the point at which I can make non-trivial modifications to it. The class of applications I have in mind are almost always written in C and run on Unixes. Historically, I have used a terminal emulator, vi, and gcc/gdb for this type of project, but would like to become more productive and take advantage of the facilities provided by an IDE. ...
0
8016
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8096
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5966
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5466
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3937
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2448
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1557
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1300
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.