LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 08-08-2005, 08:31 AM   #1
ice99
Member
 
Registered: Aug 2005
Posts: 51

Rep: Reputation: 15
help aout error script?


ok here is the problem...
with script that i have created i can copy folders fro one server to another, and the script is working ok...

but when i try to copy a folder who is not on that server the script is exiting and report error...how can i make the script to tell me that there is no folder with such name on server when i try to copy nonexisting name...just to report an error not to exit...

here is some example:


#!/bin/bash
echo -n "Enter the name from which server you are copying :"
read SOURCE
#if [ "$SOURCE" != "" ]
#then
#echo "There is no folder with name $SOURCE!"
#else
echo -n "Enter the name from which server do you like to paste the copy :"
fi
read DESTINATION

rsync -Waq /vservers/$SOURCE/ /vservers/$DESTINATION/

echo "The copying between servers was successful completed !"
thanks in advance!!!
 
Old 08-08-2005, 08:38 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
Try :
Code:
if [ -z "$SOURCE" ]; then
    echo 'operation cancelled: the user has pressed enter key'
    echo 'without giving a source directory'
    exit 1
fi
if [ ! -d  "/vservers/$SOURCE" ]; then
    echo "operation cancelled : the directory /vservers/$SOURCE does not exist"
    exit 1
fi

Last edited by keefaz; 08-08-2005 at 08:43 AM.
 
Old 08-08-2005, 08:42 AM   #3
ice99
Member
 
Registered: Aug 2005
Posts: 51

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by keefaz
Try :
Code:
if [ -z "$SOURCE" ]; then
    echo 'operation cancelled: the user has pressed enter key'
    echo 'without giving a source directory'
    exit 1
fi
if [ ! -d  "$SOURCE" ]; then
    echo "operation cancelled : the directory $SOURCE does not exist"
    exit 1
fi
ok byt now with this code i can't copy also those directories who is on the server....
 
Old 08-08-2005, 08:44 AM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
My bad

I forget to use the full path to $SOURCE directory, see the edited post
 
Old 08-08-2005, 08:48 AM   #5
ice99
Member
 
Registered: Aug 2005
Posts: 51

Original Poster
Rep: Reputation: 15
Re: My bad

Quote:
Originally posted by keefaz
I forget to use the full path to $SOURCE directory, see the edited post

THANKS MAN YOU ARE THE BEST!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables script error(?) 386 Linux - Networking 1 10-08-2005 02:56 PM
Please check this script for error AxXium Linux From Scratch 5 07-18-2005 04:40 PM
error in alsaconf script rgiggs Slackware 2 07-21-2004 12:42 PM
simple script but error ryedunn Programming 4 03-11-2004 08:02 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 05:21 PM


All times are GMT -5. The time now is 11:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration