473,467 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

chdir doubt

89 New Member
Hi,

I am using a command as below in my script to change the directory. If the $dir is not available, the program dies.
I want to add some more functionality. For example, I want to send a mail before it dies. How do I do it? I know how to send e-mail but want to know how the existing code canbe changed in order to handle? Before or die in the code? Thanks.

Expand|Select|Wrap|Line Numbers
  1. chdir($dir) or die "Can't chdir to $dir ! \n";
Aug 18 '08 #1
2 1135
KevinADC
4,059 Recognized Expert Specialist
Expand|Select|Wrap|Line Numbers
  1. chdir($dir) or send_an_email($!);
  2.  
  3. sub send_an_email {
  4.    my $error = $_[0];
  5.  
  6.    # here you send the email however you want
  7.    # include $error in the email 
  8.  
  9.    exit(0);
  10. }
Aug 18 '08 #2
lilly07
89 New Member
ok many thanks for your response.
Aug 20 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andrew Crowe | last post by:
Hi guys, We're using the ISAPI version of PHP with IIS5.0 On some websites for some reason any php file in the websites root is given the path winnt/system32 (getcwd() returns...
5
by: Nicholas Geraldi | last post by:
I have a script that uses the chdir() function. I know the script works ( works perfectly on my host ), but when I put the script on my server here at work I get the following error. Warning:...
0
by: Jon Schull | last post by:
I find that cgitb fails to show error context if I've changed my default directory, so I tried to subclass cgitb and get it to save the directory we were in when the program started. Didn't work. ...
4
by: Yun Mao | last post by:
Hi, How to make changes to os.environ and os.path.chdir still effective after I run the script? Currently, the changes are only good within my script. I would like the shell who called python...
0
by: Tom McDavid | last post by:
I'm trying to learn more Python and have come across a strange behavior. I have Python2.3 installed on a Win2K machine. If I start the python command line, I can do the following: Python 2.3.2...
3
by: dannycolligan | last post by:
I have a strange problem with os.chdir... here is my script that I am using to edit the filenames of my music library: #!/usr/bin/python from os import * ...
5
by: HMS Surprise | last post by:
Tried executing os.chdir("c:\twill") from a python Tk shell and got the error message: WindowsError: The filename, directory name, or volume label syntax is incorrect: 'c:\twill'. I have the...
0
by: Julien Biezemans | last post by:
Hi everyone, I've written a file:// scheme stream wrapper that acts like chroot() (but is more flexible, does not require root privileges and works on any platform). Everything works just fine...
4
by: rdoneil | last post by:
I am in unix and in my perl program, I am trying to move back to the directory the program was originally started in. Obviously, at somepoint in my program it has to move to another directory, and...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
1
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.