Sponsored Content
Full Discussion: Question about Setting Flags
Top Forums UNIX for Dummies Questions & Answers Question about Setting Flags Post 302184420 by chris1234 on Friday 11th of April 2008 12:18:44 PM
Old 04-11-2008
Question about Setting Flags

I have a script which will look for a test folder under the parent directory. If the folder contains test folder then create the same directory structure in other remote machine.

Once the directories are created then transfer all the contents of that test folder.

this is what i am doing :-

Code:
LOG_FILE_DIR="/home/chris/" 
   LOCAL_LOG_FILE=$LOG_FILE_DIR/"server_`date +%m%d%Y`.log" 
   SENDMAIL=0 
   MAIL_FILE=tmp.txt 
   REMOTE_DIR="/home/john" 


   cd /home/mike
   for dir in *; do
   if [ -d ${dir}/"test" ]; then

   /usr/local/bin/ssh -l melo ferrari "mkdir -m 777  $REMOTE_DIR/$dir" >>$LOCAL_LOG_FILE 2>&1
   STATUS=$?
   echo "Status = $STATUS"
   if [ $STATUS != 0 ]; then
   SENDMAIL=1
   echo "Cannot create directory $dir " >> $MAIL_FILE
   fi

   scp -r ${dir}/"test" ferrari:$REMOTE_DIR/${dir}/
   TESTING=$?
   echo "Testing = $TESTING"
   if [ $TESTING != 0 ]; then
   SENDMAIL=1
   echo "Cannot SCP for $dir " >> $MAIL_FILE
   fi

   fi 
   done

   if [ $SENDMAIL != 0 ]; then
   mail -s "Script Failed" chris1234@hotmail.com <$MAIL_FILE
   fi
   
   exit 0

The first time the script runs the value for STATUS is 0 but the second time the script runs the value for STATUS is 2. The first time directories are not created in the remote machine that is why the value for STATUS IS 0. The second time the value is 2 because the directories already exist in my remote machine.

So because of the value for STATUS is 2 i always get an email that "It failed to create the directory" because the directory already exist.

How can i get rid of that STATUS = 2 value? I mean is there any alternative?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

if flags

Hi folks. I'm just starting to teach myself shell scripting and am having some trouble with an if statement. I am working with a directory where only one file will reside at a time and need to evaluate if this file is compressed to determine subsequent steps. I'm using echo for testing purposes.... (2 Replies)
Discussion started by: kristy
2 Replies

2. AIX

question concerning Grep flags

Hey all. I am trying to find a process that is running and appending it to a file. The comman I am using is ps -eaf |grep tctl. The problem is, it returns the tctl process as well as the grep process that I just ran. Is there a flag that will prevent the command from returning itself? ... (2 Replies)
Discussion started by: jalge2
2 Replies

3. UNIX for Dummies Questions & Answers

Basic question about setting up new users

I currently have one user (USER1) that's a member of group 'A'. I want to create a bunch of users and have them all have access to READ all of USER1's files. Should I create all of the new users and have them all be members of a new group (group 'B')?? It looks like when USER1 creates a file it... (2 Replies)
Discussion started by: FredSmith
2 Replies

4. UNIX for Advanced & Expert Users

Processes Communication Only with flags!

hello everybody and a happy new year! i am trying the client-server model...i have no problem with sockets etc... especially for server:there is a father who is listening for TCP connections from clients,the later send commands which parent shares to his children. then children execute... (1 Reply)
Discussion started by: vaggelakis
1 Replies

5. IP Networking

arp output (flags)

I'm running an arp -an on a Solaris 10 box. We're using IPMP. One of the systems is not able to see a host on the same network. The only difference between the two systems (one is having a problem, the other isn't) at least so far is the output of arp: # arp -an | grep 224.55 e1000g5... (1 Reply)
Discussion started by: BOFH
1 Replies

6. UNIX for Dummies Questions & Answers

WHat are flags?

Can anybody actually tell, what is flag? I know they are termed as permission flags and various others. Please explain (3 Replies)
Discussion started by: nixhead
3 Replies

7. UNIX for Dummies Questions & Answers

Ifconfig Flags

Hi there, I need your help in understanding the below Solaris 10 ifconfig output; athnetspns02>ifconfig -a lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0:... (2 Replies)
Discussion started by: wthomas
2 Replies

8. UNIX for Beginners Questions & Answers

Question about setting up a hard drive for a videoserver under Linux

Hi there, I'm currently preparing for an exam and came across a question that I don't really know how to answer. "You want to set up a hard drive for a videoserver under linux. - The videofiles will have a size of at least 10MB and a maximum of 8BG. - The hard drive has a disk space of... (1 Reply)
Discussion started by: Eggsy
1 Replies

9. Homework & Coursework Questions

Question about setting up an hdd for a videoserver

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: You want to set up a hard drive for a videoserver under linux. - The videofiles will have a size of at least... (1 Reply)
Discussion started by: Eggsy
1 Replies

10. UNIX for Beginners Questions & Answers

View file flags

hello: how could i view the file's flags? "ls -loa" doesn't seem to do the trick: root@giraffe:/etc # ls -alo total 820 drwxr-xr-x 23 root wheel - 2048 Oct 23 19:48 . drwxr-xr-x 19 root wheel - 1024 Nov 16 15:01 .. drwxr-xr-x 2 root wheel - 512 Nov 11 2014 X11... (6 Replies)
Discussion started by: ipfreak
6 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 10:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy