hello everyone.. i want to make a file which, when u run it, it asks for your name and how many times you want to see your name displayed.. the program ever 10 times it will ask you if you want to continue and u have to answer with Y or N. if you type Y it continues displaying your name from where it stopped, if N it breaks.
for example i choose 45 times..
it will show
Name 1
Name 2
...
Name 10
Do you want to continue? Type Y/N
etc..
here is the code..
the program works fine except for the part of the question to continue or stop.. some help please?
---------- Post updated at 02:23 AM ---------- Previous update was at 02:21 AM ----------
i want to mention that i only created the code for the first 10 pack of displays..
Your problem is that when you reach the desired count, the while loop exits. You need to wrap your while inside of an outer while and move your prompt outside of your inner loop.
Along the lines of:
This logic is a bit flawed inasmuch as it will prompt if count is reached and is a multiple of 10, but it should give you an idea.
It's possible to add spaces at the front of your code to allow yourself to organize it logically.
The very first thing your program does is increment i, so that by the time you check it, it's skipped straight past 1 and gone to 2, so it never asks. So, check first, then add after the case statement.
As for stopping every 10 times, I see two obvious approaches.
1) Have two independent variables. One of them trips the case statement every 10 loops and drops back to 1 when it does. The other just gets incremented continually until the while statement becomes false.
2) Use the modulus ( % ) mathematical operator:
It's the integer remainder when dividing. You can see it drops to zero whenever it divides evenly. You can use that to see whenever the number is an even multiple of something.
hi guys....in my code the echo statements inside case statements are not printing the required display info....pls help me out
#!/bin/bash
tput clear
tput cup 3 15
tput setaf 3
echo "BACKUP PROJECT"
tput sgr0
tput cup 5 17
tput rev
echo "select option"
tput sgr0
tput cup 7 15
echo... (12 Replies)
I have the following bash script and it is not accepting the lines
"--"|"--""-")
"--""-"")
while
do
echo "Current Argument is ${1}"
case "$1" in
"--"|"--""-")
echo "Argument is ${1}"
shift # Skip ahead one to the next argument.
... (1 Reply)
Hi,
When I execute the below script, I am getting the error as
' is not expected.ror at line 3 : `in
#!/bin/sh
case $1 in
-r) echo Force deletion without confirmation ;;
-i) echo Confirm before deleting ;;
*) echo Unknown argument ;;
esac
I could not see any problem with... (1 Reply)
Guys,
Here is the script syntax which is not accepting the parameters & not performing the said activity.
$ ./routing.sh xyz123-ra str enable
**********************************************************************
Preparing to service the request for Device xyz123-ra in Question... (9 Replies)
Hi,
I need modify the all lines in a file into one format.
cat file
htec.twe34c.ATI
.hesh.twdghu..ATI
..hesh.twdghu..ATI
htec.twe3
hjsct14567ati
Output should have 16 characters
htectwe34c ATI
heshtwdghu ATI
heshtwdghu ATI
htectwe3 ATI
hjsct14567 ATI (4 Replies)
Hi there,
Im having some problems with this function, I pass two arguments to the function $1 $2 (Arguments are month and date inputted by the user)
for some reason the case always fails... however in the cases defined below where it shouldnt fail the result is:
if it fails with input... (6 Replies)
I am using ksh on a HP Ux. I have a simple script but am having problem with the case statement:-
#!/usr/bin/sh
Chl=”SM.APPLE_SWIFT_DV”
LoConfirm=””
case $chl in
)
LoConfirm=”Using channel at Building 1”
echo “test conditon1”
echo $LoConfirm;;
)
LoConfirm=”Using... (2 Replies)
I need to display this menu and accept variables. Can someone tell me why i am having a problem with this case statement, please
# TAPE MANAGER MAIN MENU
tapemgr_Main_Menu()
{
echo "Legato Tape Management System Menu"
echo " This system is used to report Legato ERV Offsite and Tapes... (6 Replies)
I'm trying to run a ksh script with a case condition to handle parameters.
#!/bin/ksh
db_start(){
*code
}
db_shut(){
*code
}
case "$1" in
up)
db_start TRNG
;;
down)
db_shut TRNG
;;
*)
echo "Usage: $0 { up | down }" (3 Replies)
Hello,
I am having a problem setting a range of numbers for the "case" structure.
I can use with no problems, but
when I use it doesn't work???
Does the case struture allow numeric ranges?
eg:
echo -e "enter number between 0 and 60: \c"
read $answer
case $answer in
) echo... (2 Replies)