While Loop Not Working

Hey, not sure if this is the best place however thought id ask my question ..

My while loop below doesnt return as id expect :

while [[ ! "$RES" =~ (1|2|3|4|5|6|7|8|9|x|10)$ ]]
do
read -p "Please select an above option : " RES || exit
done

if [[ "$RES" =~ 1 ]]
echo "Option 1 Selected"
and so on through all my results

This goes on and works all the way up to 10.

If i select option 10 it runs option 1.

Any idea how to make sure when i select option 10 it runs it not 1.


Similar Content



Triple Boot Problem: Unable To Add 3rd System With Bootable USB

Hi All,

I recently decided to tryout Linux and dual booted my laptop (originally just had windows 8) with Xubuntu. Now I want to try out Kali Linux. So I downloaded Kali and made a bootable USB, the problem is that when I try to boot from the USB it just brings up the grub menu asking me to select Xubuntu, Windows etc. I've changed the boot menu in the BIOS but that has no effect.

I've tried booting into windows and the restarting by holding shift but when I select the usb option it just says:

"system doesn't have any USB boot option. Please select other boot option in Boot Manager Menu"

and then returns to the grub menu. I don't understand because I used a bootable usb to install xubunto?

I'd be really grateful if anyone can help me out with this!

Thanks

Trying To Install Korora 21 But Haning.

I've been testing out a couple of LiveDVD systems and I like Korora 21. I'm now trying to install this distro but the Anaconda Installer does not seem to be working.

Each time I get to the screen with the keyboard, date/time and installation destinations. The Data/time and INstallation destinations options have a white box around them. The Date/Time shows a message "Restoring Hardware time" or something like that and the Installation Destination is showing a message "Probing Storage".

I've let it sit for about 10 minutes and nothing changes. I've tried clicking on the Date/Time option and the Installation Destination option with no luck. When you hover over the Installation Destination option it shows "No Disks Selected".

Can someone help me with this please? I really like the LiveDVD and would like to give it a go.

Starting Dhcp Failed

I am novice at linux...I installed VMware work station and then install centos 6.4. Now I followed this tutorial to configure DHCP Server on my OS http://tecadmin.net/configuring-dhcp...centos-redhat/
but when start dhcp I see this : Starting dhcpd:[FAILED]
This is my /etc/dhcp/dhcpd.conf

option domain-name "center.local";
option domain-name-servers master.center.local;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-search "center.local";
option domain-name-servers 192.168.1.100;
option time-offset -18000; # Eastern Standard Time
range 192.168.1.100 192.168.1.120;
}

host station1 {
option host-name "centos-1.center.local";
hardware ethernet 00:11:1A:2B:3C:AB;
fixed-address 192.168.1.101;
}

so what is wrong?Any suggestion?
Thanks for your help and sorry for my bad English grammar

Empty Trash Bin Option

I am using Slackware 14.1, with the KDE desktop environment.

How do I add the option "Empty Trash Bin" to the trash bin icon that is shown in the command line at the bottom of the screen? If I right-click the icon I only see options "Trashcan Settings" (which does not offer what I want!) and "Unlock Widgets".

I currently empty the trash bin by left-clicking on it and using Konqueror.

Check Empty Variable Without Comments

Hello,

They gave me this:
Code:
#!/bin/bash

# Write error message on stderr and die
function die() {
  echo "$@" >&2
  exit 1
}

# Load var from properties files
function load() {
  for propertie in "$@" ; do
    [[ -f "${propertie}" ]] || die "load() : \"${propertie}\" don't exist !"
    while read ; do
echo "${REPLY%=*}"
echo "${REPLY#*=}"
      [[ -n "${REPLY%%=*}" && -z "${REPLY#*=}" ]] || die "load() : Variable \"${REPLY%%=*}\" is empty!"
      eval "${REPLY%%=*}"=\'"${REPLY#*=}"\'
    done < "${propertie}"
  done
}

load "manage_srcds.conf"
echo "SRCDS_TICKRATE=$SRCDS_TICKRATE"
echo "SRCDS_SCREEN=$SRCDS_SCREEN"
echo "SRCDS_SRCDS_GAME_NAME=$SRCDS_GAME_NAME"
echo "SRCDS_MAXPLAYERS=$SRCDS_MAXPLAYERS"

but, return:
Quote:
###################################################
###################################################
load() : Variable "###################################################" is empty!

cat manage_srcds.conf

I just wish that there was no empty variable excluding those who do not have integer.

Best regards,

How To Return From Shell 'read' Command Passed In Expect Script?

I have a shell script that calls an expect script I wrote to ssh login to another host and get user input regarding that host's network configuration. I pass four arguments to the expect script: the remote host ip address, the username, the password, and the list of commands to run. My expect script is below:

#!/usr/bin/expect
# Usage: expectssh <host> <ssh user> <ssh password> <script>

set timeout 60
set prompt "(%|#|\\$) $"
set commands [lindex $argv 3];

spawn ssh [lindex $argv 1]@[lindex $argv 0]

expect {
"*assword:" {
send -- "[lindex $argv 2]\r"
expect -re "$prompt"
send -- "$commands\r"
}

"you sure you want to continue connecting" {
send -- "yes\r"
expect "*assword:"
send -- "[lindex $argv 2]\r"
expect -re "$prompt"
send -- "$commands\r"
}

timeout {
exit }

expect -re $prompt
send -- "exit\r"
}

The script runs well, except that if I send a command such as 'read' that requires user input, the script does not continue or exit after the user presses enter. It just hangs.

The commands I pass to the expect script and it's call are as follows:
SCRIPT='hostname > response.txt;netstat -rn;read net_card?"What is the network interface card number? " >> response.txt; read net_mask?"What is the subnet mask? " >> response.txt'

/usr/bin/expect ./expectssh.exp $hostip $usr $pswd "$SCRIPT"

Any suggestions on how I can pass a command to my expect script that requires user input without it hanging?

On a side note because I know it will come up - I am not allowed to do key-based automatic SSH login. I have to prompt for a username and password, which is done from my main shell script.

Thanks for any suggestions and help you can provide!

Parameter $1 Isn't Returned After A Case (bash Scripting)

Hello everyone,

I recently started using "function" and "case" in linux but I came across a slight problem

My code:

Code:
function Return
{
echo $1
}

case "$1" in 
 ""       ) echo "give parameters please";;
 [0-9]*   ) echo "No numbers please";;
 *        ) Return;;



So whenever the first parameter is a simple word I would like it returned, but it seems like there is no returned string (empty space)

Also I know I can just write "echo $1" instead of Return, but I'd like to use a function for this.

Can anyone tell me why the function doesn't return $1? Thanks!

Toshiba A205-S4577 Will Not Boot.

I have a Toshiba laptop that will not boot. I get to the grub menu which gives me the option to load Ubuntu, Ubuntu recovery mode, or a couple of memory tests.

If I select Ubuntu I get a black screen with a flashing cursor in the top left corner.

Selecting recovery mode gives me a lot of messages with the last one being "EDD information not available".

The memory test option does not return any errors.

If I try booting Mint from a bootable DVD I get the Mint screen and then it goes gray with a flashing cursor in the top left corner.

Any suggestions?

Help With 'CASE'

Hi guys,

i'm beginner with Unix, I tried my best, but I Really don't know how to finish it .

here's my problem : I have to do something like Student system - student's name | subjects | mark |credits.

after starting script it will ask you for Student's name, then which subject, then the mark will appear.

It's a homework, and I have my own idea how to solve it, but cannot finish it, i don't want complete solution, just a help!

Code:
#!/bin/bash
echo "Students name"
echo -n "Enter student's name: "
read name
echo
case $name in
Example1|Math) echo "C" ;;
Example2|Programming) echo "D" ;;
Example3|WWW) echo "A" ;;
Example4|Economie) echo "-" ;;
esac

I don't now how to bring together case with second things which is "enter subject".

I appreciate any help

Rsync Script Problem

Hi all,

I am trying to write a script that syncs files from source to destination. I have one centralized server that can ssh to any servers without pw. Now when I run the script, it can ssh to source server perfectly fine, but you need to enter password for destination server. Was wondering how I can clean this up before I start using case statements

Below is a sample I wrote

#!/bin/bash

#This scripts syncs shit

echo "Type in ID: "
read ID

echo "Type in Server : " #source server
read S

echo "Type in Destination Server: "
read DS

if [ $S == 9 ]; then
ssh -t "root@"$S"webserver1" "rsync -av /home/rlui/"$ID "root@"$DS"webserver2:/home/rlui/";
ssh -t "root@"$S"webserver1" "rsync -av /home/rlui/tmp/"$ID "root@sl"$DS"webserver2:/home/rlui/tmp/"
exit 1

where S and DS are cluster numbers

I apologize in advance if I am not clear on anything