Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-11-2014, 03:22 AM   #1
Registered: May 2013
Posts: 189

Rep: Reputation: 1
A shell script for svn update

I have created script according to specifications but still I am facing problem, please help me.

Here is the environment.
a) Projects are deployed in htdocs, there is a folder with same name as repository in htdocs, in this folder there are two folders i.e. staging and production and in these both folders project is checked out.
b) Some projects are checked out in htdocs directly, There are no staging and production copies for direct checked out project.
c) Rest are data directories in htdocs, they are not related to svn.
d) There are all types of directories in htdocs. Some has staging and production directories, project is checked out directly in some directories and others are only data directories, they are not related to svn.

Here are the requirements.
a) First show all created repositories of svn.
b) Update the staging and production copies, do not update direct checked out projects.

Here is my script
echo "Here is the list of current repositories"
cd "$svn_repo_path" && ls
echo "Enter repo name whose production and staging copies you want to update in htdocs"
read up_repo
[[ "$up_repo" == "q" ]] && exit 0
if [ -d $up_repo ]
cd "$htdocs_path/$up_repo"
if [ ! -e \.svn ]
echo "Enter one of the following directories whose repo you want to update"
ls -l | grep ^d | awk '{print $NF}'
read up_repo2
if [ -d $up_repo2 ]
cd "$htdocs_path/$up_repo/$up_repo2/$up_repo" && svn update
echo "Directory not exist"
echo "There are no production and staging copies available in the directory."
echo "Repo does not exist, create Repo first"
The problem is when it waits on read and I press return key without enter anything, it shows the list of all directories of htdocs. I do not want that it should list the htdocs directories.

Please help.
Old 01-11-2014, 05:53 AM   #2
LQ Veteran
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
You could set a default value:
read -p "Enter repo : " REPO1
# set a default value if empty
echo $REPO1

# or
read -e -p "Enter repo : " -i "Default_Value" REPO2
echo $REPO2
In most cases I prefer the first one. The second one echoes the default value and then asks the user to do something with it.
1 members found this post helpful.
Old 01-11-2014, 08:55 AM   #3
Registered: May 2013
Posts: 189

Original Poster
Rep: Reputation: 1
Thanks druuna, it worked.

I know my script is full of mess and no one will suggest that use this.
Can you please help to improve it, what should I do to make it clean.


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
Svn client on FC10: remote SVN server update errs: timed out waiting for srvr ... Amol Tupe Linux - Software 0 10-01-2010 04:25 AM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 11:48 PM
Shell script to update IP kidestranged Programming 4 02-02-2007 08:57 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
update oracle table using shell script ann124 Programming 1 12-06-2004 03:42 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:53 PM.

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