Bash Script Read user input into arrays?
location: ubuntuforums.com - date: July 11, 2010
Can someone please tell me if there is a way to store user input in bash script into arrays?
read 12345 and store it as 1 2 3 4 5 each in a different variable,I've searched and I think what I am looking for is arrays but I wasn't able to find something that takes the user input into arrays. I'm using
read var1 var2 var3 var4 var5
as a workaround but it needs the user to add a space in between the integers. So it would be best if there is a way to eliminate that.
Lastly, have a nice day everyone!
Bash script predefined user input
location: linuxquestions.com - date: August 9, 2009
Its my first post here so please be gentle to me
I have a script im having some problems with, what I need is to have the system generate a random password for me and use that password when creating new users to it.
System is Debian Lenny and script is in bash.
The program is znc. I have made it so that it will generate the random password on the shell but the problem is to use it in the bnc software. To make a password there the command is znc --makepass and look like this:
debian# znc --makepass
[ ?? ] Enter Password:
[ ?? ] Confirm Password:
[ ** ] Use this in the <User> section of your config:
[ ** ] Pass = md5#9463a1389d1454b139b610f032ab4c74#WemSsk6USR0+51V-ZKXh#
My question is now if it would be possible to put in the script so it would "answer" when it need those passwords ? the random password that is generated is in a variable called $setpass and is NOT crypted.
Or is there any other software that would be able to generate t
Using Bash Script to feed input to command line
location: linuxexchange.com - date: January 1, 1970
So I am trying to make a bash script that calls this one command and then feeds it the input. It calls this one command and the command needs 3-4 inputs after. I type the command and it waits for me to enter first name, one I enter first name it waits for me to enter last name, and so on. How can I use bash script to pass these arguments to the command one at a time?
Bash Y/N user input
location: linuxquestions.com - date: April 15, 2008
Got a quick question about a bash scripti I'm putting together. I'm writing a script that I want to have a user select Y/n. Y being the default if they just hit enter to pass.
One issue I was having was it only accepts capitol case input.
What the script will be doing is line by line installing some rpms (example)
Would you like to install John The Ripper Y/n?
If they go with yes it runs yum install -y john
if they go with No it moves to the next question asking about an install.
I know its a little vague.
[SOLVED] bash script: wait for input from kdialog before doing sth.
location: linuxquestions.com - date: May 27, 2011
The goal of the script is the following:
Whenever I leave my house, my wife comes to my computer to check her mails (She has two computers of her own but they have a dangerous operating system, so they have been banned from the internet).
She shuts down qbittorrent so as to download all her mails, and she forgets to execute it again on 98% of the times. End result: my computer is sometimes turned on for 10 hours doing absolutely nothing.
I had therefore two choices: a) get on my wife's nerves until she gets the problem or b) write a bash script.
If you are married, you will understand that bash scripts are easier to deal with than spouses.
Ergo, I wrote the following script:
Bash Script: "Yes/No" User Input.
location: ubuntuforums.com - date: August 21, 2007
I have begun playing with bash scripting and i want to make a very simple script for when i do a fresh reinstall.
Simply it is a list of:
"Sudo apt-get install XXX
Sudo apt-get install YYY...etc"
What i want to do is put in a question before each install so its something like:
"do you want to install XXX?
If yes sudo apt-get install XXX
if no continue onto the next line
do you want to install YYY?
If yes sudo apt-get install YYY
if no continue onto the next line...etc"
Bash script yes/no user input
location: ubuntuforums.com - date: July 21, 2010
Trying to make a bash script that will ask a user weather they want to do something or not: Need to invert the boolean on the until loop and get the second if to use "And" syntax (Just for the sake of learning)
until !$loop; do
echo -n "Do you want to block advertisements and potential malware with a hosts file? [y/n] "
if [ -n "`echo "$input" | grep -i [ny]`" ]; then # If theres a y or n in the answer
if [ -n "`echo "$input" | grep -i y`" -a -n "`echo "$input" | grep -i n`" ]; then # If theres a y but no n
loop=false #Finish the loop no matter which answer
echo -n ""
Help me read user keyboard input inside a while loop in a bash script
location: ubuntuforums.com - date: October 20, 2009
Thanks in advance for reading this! I'm having trouble getting user input in a bash script. Normally I have no problems using the bash "read" builtin. But for some reason, when I try to get user input inside a while loop, the "read" function REFUSES to stop and wait for user input! Here's the offending code snippet:
while [ $execute -eq 3 ]
read -p 'Type "yes" to execute, "skip" to skip for this file, or "exit" to stop.' confirm
case $confirm in
"yes") execute=1 ;;
"skip") execute=0 ;;
"exit") exit 0 ;;
* ) execute=3
echo 'Please enter a valid option.'
This is part of a larger script, but the rest of it worked fine until I added this (the "interactive" mode for my script). The result running this is an infinite stream of "Please enter a valid option." with
User input using a BASH script...
location: linuxquestions.com - date: July 12, 2003
I'm trying to write a menu in BASH that would accept a user's input with one kestroke. For instance, if the menu contained these options:
... a user could simply type the number three without having to press the enter key for the script to read the input. I've read through a couple of tutorials and they use the "echo -n" and "read" combination in their scripts which isn't what I want to do. I would like to minimize the amount of keystrokes a user would have to make.
I also happened upon the dialog utility to make text boxes for menus. Will this help in creating the one-keystroke functionality I'd like to have?
How do I make my BASH script yes/no user input query terminate with 3 invalid inputs?
location: linuxquestions.com - date: March 16, 2010
I have a BASH script which at one point asks the user a yes/no question. I want to make it so that if the user types in an invalid input 3 times consecutively then the BASH script will echo an error and terminate with exit status 1.
Here is my current code:-
Page: 1 2 3 4 5 6 7 8 9 10