Solved

Need some interactivity in a shell script...

Posted on 2006-11-30
2
217 Views
Last Modified: 2010-04-20
Hello, I want to run these commands in a bash shell script

rug service-list
rug refresh
rug list-updates
---ask root here---
rug update  (*)

Before (*) is executed I want to ask the user (mostlikely root), if he agrees (some press "y" to execute question)
If anything else is pressed like "n" (*) command should be skip and that batch file finished.

Reason: "rug list-updates" gives me a list all new updates and there might be a reason to skip the automatic update.

This is for SLES 10 yum update proxy.

Thank you,
Tolomir
0
Comment
Question by:Tolomir
2 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 200 total points
ID: 18051965
Hi Tolomir,

echo -n "do you wish to continue (y/n)?"
read var

#use $var here to determine your actions
if [ "$var" = "n" ]
then
      echo "you entered n"
else
      echo "you did not enter n"
fi

Cheers!
sunnycoder
0
 
LVL 27

Author Comment

by:Tolomir
ID: 18052053
Cool, thank you.

Tolomir
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now