Solved

Shell script

Posted on 2011-03-14
2
445 Views
Last Modified: 2013-12-28
Hi Friends,
Need your help to draft shell script which will perform following functions.
Source file, which contains first argument as server name, second argument filesystem type and third is command to take backup.

Filename - servername.txt
Servername:/var/log:arc
Servername:/var/:backup
Servername:/var/log:qfiles
Servername:/var/log:arc

The script will first scan the servername.txt file, and depending on the second and third argument it will execute shell script.
If the second and third argument is “/var/log” and “arc” then it will execute the script 1
If the second and third argument is “/var/” and “backup” then it will execute sscript2
If the second and third argument is “/var/log” and qfiles  then it will excute script3
If the second and third argument is “/var” and “qfiles” then execute script4
Else argument specified is not valid.
Thanks
0
Comment
Question by:rameshsukhi123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Expert Comment

by:Amick
ID: 35125878
for spath in $(cut -d: -f2-3 servername.txt)
do
case $spath in
/var/log:arc)
	echo script1 ;;
/var/:backup)
	echo script2 ;;
/var/log:qfiles)
	echo script3 ;;
/var/:qfiles)
	echo script4 ;;
*)
	echo spath not processed. ;;
esac
done

Open in new window

of course instead of echo you'll want to execute the appropriate script.
0
 
LVL 8

Accepted Solution

by:
point_pleasant earned 500 total points
ID: 35128691
amick's script will not work to execue script4 should be "/var:qfiles"  hear is a script that actually gets both variables (i.e. the filesystem type on the back up type).  should also be easire to add more filesystems and backup types.


Mike

for i in `cat ./bck.tct`
do
        file_system=`echo $i | cut -f2 -d:`
        back_up_type=`echo $i | cut -f3 -d:`
        case $file_system in
        /var/log)
                case $back_up_type in
                        arc)
                                echo script1
                                ;;
                        qfiles)
                                echo script3
                                ;;
                        *)
                                echo "SPECIFIED ARGUEMENT NOT VALID"
                                ;;
                esac
        ;;
        /var/)
                case $back_up_type in
                        backup)
                                echo script2
                                ;;
                        *)
                                echo "SPECIFIED ARGUEMENT NOT VALID"
                                ;;
                esac
                ;;
        /var)
                case $back_up_type in
                        qfiles)
                                echo script4
                        ;;
                        *)
                                echo "SPECIFIED ARGUEMENT NOT VALID"
                        ;;
                esac
        ;;
        *)
                echo "SPECIFIED ARGUEMENT NOT VALID"
                ;;
        esac
done
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question