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)							      General Commands Manual							    rmf(1)

NAME
rmf - remove folder (only available within the message handling system, mh) SYNOPSIS
rmf [+folder] [-help] [-[no]interactive] OPTIONS
Prints a list of the valid options to this command. Asks for confirmation before deleting a folder. By default, rmf deletes a folder and its messages without asking for confirmation. If you specify the -interactive option, rmf asks if you are sure before deleting the folder. You are advised to use this option, since when rmf deletes a folder its contents are lost irretrievably. DESCRIPTION
The rmf command removes all of the messages within the current folder, and then removes the folder itself. If there are any files within the folder which are not part of MH, they are not removed, and an error message is displayed. You can specify a folder other than the current folder by using the +folder argument. If you do not specify a folder, and rmf cannot find the current folder,rmf asks you whether you want to delete +inbox instead. If the current folder is removed, it makes +inbox current. Note that the rmf command irreversibly deletes messages that do not have other links, so use it with caution. If the folder being removed is a sub-folder, the parent folder becomes the new current folder, and rmf tells you that 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. Using rmf to delete a read-only folder deletes the private sequence and current message information from the file, without affecting the folder itself. If you have sub-folders within a folder, you must delete all the sub-folders before you can delete the folder itself. PROFILE COMPONENTS
Path: To determine the user's Mail directory EXAMPLES
This example shows how rmf asks for confirmation when the -interactive option is used: % rmf -interactive +test Remove folder "test"? y FILES
The user profile. SEE ALSO
rmm(1) rmf(1)
All times are GMT -4. The time now is 12:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy