LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 01-11-2014, 03:22 AM   #1
unclesamcrazy
Member
 
Registered: May 2013
Posts: 187

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
Code:
#!/bin/bash
svn_repo_path=/path/of/svn/repositories
htdocs_path=/path/of/htdocs
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 ]
then
cd "$htdocs_path/$up_repo"
if [ ! -e \.svn ]
then
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 ]
then
cd "$htdocs_path/$up_repo/$up_repo2/$up_repo" && svn update
else
echo "Directory not exist"
fi
else
echo "There are no production and staging copies available in the directory."
fi
else
echo "Repo does not exist, create Repo first"
fi
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
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
You could set a default value:
Code:
read -p "Enter repo : " REPO1
# set a default value if empty
REPO1=${REPO1:-Default_Value}
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
unclesamcrazy
Member
 
Registered: May 2013
Posts: 187

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.
Thanks
 
  


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
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


All times are GMT -5. The time now is 08:19 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration