Sponsored Content
Full Discussion: Error code checking
Top Forums Shell Programming and Scripting Error code checking Post 302133011 by jepombar on Tuesday 21st of August 2007 12:21:56 PM
Old 08-21-2007
I'm doing it in perl

Sorry if I wasn't clear.
I need to create a folder and if there is any errors like permission errors I want to let the user know about it. However I don't wish to overwrite the folder if it already exists. Also I need to do it inside a Perl script.

This is the workaround I came up with:

`ls log 2> /dev/null`; #check if the folder exists
if($?) { #if it doesn't create it
`mkdir log`;
$dirFlag = 1; #flag to know that dir was created
}

The bad thing about this is that it wont let the user know if there were any permission errors. In other words, if the folder wasn't created for some reason the program will crash later when I try to write to that folder.

So what I want to do is to somehow check, in my Perl code, the error code that UNIX spits out. The problem is that I'm getting the same error code number for both "File Permission" and "File exists" errors.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Code checking for all values in the same if statement.

I am trying to set up a variable based on the name of the file. function script_name { if then job_name='MONITOR' return job_name; elsif then job_name='VERSION' return job_name fi } for i in `ls *log` do script_name $i done. (4 Replies)
Discussion started by: oracle8
4 Replies

2. Shell Programming and Scripting

Need help with error checking

I am creating a script that will automatically use sftp to connect to a site and download a file, extract the tar and then delete the tar file once completed. What I am stuck on is the error checking for this process. Here is the code so far: Now this works for me as is, but i need... (0 Replies)
Discussion started by: xianoth
0 Replies

3. Shell Programming and Scripting

checking the return code

hi i have a file, i am reading line by line and checking a line contains a string , `grep "Change state" $LINE` if then echo "The line contains---" else echo "The line does not contains---" i need to check the return code , but i am getting an error ... (4 Replies)
Discussion started by: Satyak
4 Replies

4. Shell Programming and Scripting

Error checking help.

I am currently wrapping up a assignment for one of my classes. I need help writing some error checking logic. The problems I am having are: keeping track of the records I have deleted and reported it back using echo. I have no idea how to do this. ensuring that line numbers fall... (1 Reply)
Discussion started by: Boltftw
1 Replies

5. Programming

code for checking username char is not present in password.

hi friends , i need c code for my app, in my app the user can create the new user for the system, while creating the new user ,i try to include the condition the user name is not present in password. my exe requrment is : the user name char is not present in password,if the password... (6 Replies)
Discussion started by: vasu28
6 Replies

6. Shell Programming and Scripting

code checking

i was just wondering how would you check , beside the lock method, if an instance of another code is already running and if it is then output a message to the user saying the program is already running and exit!! the code is in BOURNE SHELLL!!! thanks in advance!! (3 Replies)
Discussion started by: bshell_1214
3 Replies

7. Shell Programming and Scripting

Checking for duplicate code

I have a short line of code that checks very rudimentary for duplicate code: sort myfile.cpp | uniq -c | grep -v "^.*1 " | grep -v "}" It sorts the file, counts occurrences of each line, removes single occurrences and removes the ubiquitous closing brace. The language is C++, but is easily... (3 Replies)
Discussion started by: figaro
3 Replies

8. Shell Programming and Scripting

Checking LB status.. stuck in script syntax of code

#!/bin/ksh #This script will check status of load balancer in AIX servers from hopbox #Steps to do as folows : #Login to server #netstat -ani | grep <IP> #check if the output contains either lo0 OR en0 #if the above condition matches, validation looks good #else, send an email with impacted... (7 Replies)
Discussion started by: vinil
7 Replies

9. UNIX for Beginners Questions & Answers

Code for checking if certain no of files exists

Hi, I am writing the shell script in ksh to check certain no of files exists,In my case there are 7 files exist like below Sales1_timstamp.csv Sales2_timstamp.csv Sales3_timstamp.csv Sales4_timstamp.csv Sales5_timstamp.csv Sales7_timstamp.csv Sales7_timstamp.csv Once all the files... (4 Replies)
Discussion started by: SRPR
4 Replies
RMF(1)								     [nmh-1.5]								    RMF(1)

NAME
rmf - remove an nmh folder SYNOPSIS
rmf [+folder] [-interactive | -nointeractive] [-version] [-help] DESCRIPTION
Rmf removes all of the messages (files) within the specified (or default) folder, and then removes the folder (directory) itself. If there are any files within the folder which are not a part of nmh, they will not be removed, and an error will be produced. If the folder is given explicitly or the -nointeractive option is given, then the folder will be removed without confirmation. Otherwise, the user will be asked for confirmation. If rmf can't find the current folder, for some reason, the folder to be removed defaults to `+inbox' (unless overridden by user's profile entry "Inbox") with confirmation. If the folder being removed is a subfolder, the parent folder will become the new current folder, and rmf will produce a message telling the user this has happened. This provides an easy mechanism for selecting a set of messages, operating on the list, then removing the list and returning to the current folder from which the list was extracted. If rmf s used on a read-only folder, it will delete all the (private) sequences (i.e., "atr-seq-folder" entries) for this folder from your context without affecting the folder itself. Rmf irreversibly deletes messages that don't have other links, so use it with caution. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder Inbox: To find the default inbox SEE ALSO
rmm(1) DEFAULTS
`+folder' defaults to the current folder, usually with confirmation `-interactive' if +folder' not given, `-nointeractive' otherwise CONTEXT
Rmf will set the current folder to the parent folder if a subfolder is removed; or if the current folder is removed, it will make "inbox" current. Otherwise, it doesn't change the current folder or message. BUGS
Although intuitively one would suspect that rmf works recursively, it does not. Hence if you have a sub-folder within a folder, in order to rmf the parent, you must first rmf each of the children. MH.6.8 11 June 2012 RMF(1)
All times are GMT -4. The time now is 12:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy