Questions tagged [user-input]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
20 views

Set variables via user input and check all variables have been set before continuing script

I'm building an automated bash script that will install and configure several packages on a Linux Server. I'm hoping to re-use this script on multiple servers but change some parameters accustom to ...
0
votes
1answer
51 views

Why does read appear to fail silently in my script called from another script?

Let me paint a picture for your. You write some deployment scripts or build scripts or somethings etc. which run commands on the remote to do things like e.g. create users, install/update package etc. ...
3
votes
2answers
563 views

bash script - request input via gui

I'm currently writing a nemo action script in bash, and I need a way to get input from the user. How?, the terminal isn't showing when running an action script. is there anyway to popup a query window ...
2
votes
2answers
31 views

How can I modify input variables with string modifiers in zsh?

I've been working on a bold function as a proof-of-concept and a challenge to myself. I am trying to input text (e.g.foo) and have it print to standard output as it's bold counterpart (foo). Context: ...
0
votes
1answer
26 views

Printing all lines between two strings, with one as a user input, using sed [duplicate]

I'm trying to use: sed -n '/String1/,/String2/p' Filename to print all lines between String1 and String2. Although I want to add String1 as a user input so, read $userinput sed -n '/$userinput/,/...
-1
votes
1answer
66 views

How to create a shell script that would create a copy of a file (selected by the user) and copy it to a directory (selected by the user) in Bash?

How to solve this task? To create a copy of a file. The file should be in your current directory (the name of the file to be given by the user) The destination directory name to be ...
2
votes
1answer
154 views

Script that validates 3 inputs

This is what I have. I am trying to validate 3 inputs. The first and the second inputs do not ask me to enter the correct input. What is wrong? #!/bin/bash ...
2
votes
1answer
230 views

zsh script prompt reading single keystroke: add newline when appropriate?

I have a script that takes an -i flag (→ $interactive) and if set, asks a yes/no-default-no question for each target, à la rm -i and others. Zsh’s read -q is designed for this exact case—it accepts a ...
0
votes
1answer
312 views

How do I test the output of grep, with an if statement

I need to use an if statement to respond to a blank output. I've got: while read -p "Enter filename: " do Extant=$(ls | grep $name) echo "$Extant" to store and display the results. that's fine... ...
0
votes
2answers
64 views

How do I prompt for user input using $EDITOR from a script?

I want to have an input mechanism akin to git commit. When the script is run, it should open an editor to edit a temporary file, use this file as my input, and then get rid of the file.
0
votes
1answer
98 views

How may I detect if the number of input is within the limit

I want to read three inputs and want to count them so that I can display a custom error message if the user inputs less than three or more than three. The code for the program I'm trying to write is ...
2
votes
4answers
418 views

Why do control-left and control-right (arrow keys) not navigate by word in `less`?

In less's line editing mode, the left and right arrow keys move the cursor backwards and forwards. I was hoping to use these together with the control key to navigate by word, as promised by man less. ...
0
votes
2answers
819 views

Removing login username password screen to Autologin

I am using UP Board. IT has Ubilinux installed in it. I have made a browser kiosk so that it automatically logs in to the browser full screen mode but I am having an issue on reboot. Whenever I try to ...
0
votes
1answer
17 views

loop user inputted string in script

trying to make a basic addition function that adds the numbers entered and outputs a total. Here's my current function: function addition() { read -a arr for i in ${arr[@]} do ...
-1
votes
1answer
261 views

How to check every file in directory and ask the user to do action in csh shell

The actions I would like to do with this script is to Read the name (without base) of each file in a directory For each file, ask the user if he wants to perform an action (e.g. move the file in a ...
3
votes
4answers
3k views

Pasting multiple commands into terminal stops at user input

Pasting some consecutive commands into terminal stops on commands with user input, e.g.: read VAR echo $VAR or select VAR in 1 2 3; do break; done echo $VAR echo $VAR is not getting pasted/...
0
votes
1answer
553 views

Give default path for id_rsa in a shell script

I want to automate user creation along with the rsa key generation in a shell script. But while generating the rsa key we need to give inputs for these three things. Enter file in which to save the ...
0
votes
2answers
3k views

Wait for keyboard input inside a while-read loop

I have a bash script with a construction like this: while read foo bar baz; do echo "Processing $foo $bar $baz" # more code here done < /etc/somefile Inside the loop, I would like the ...
0
votes
1answer
37 views

New to Unix, want to create a simple user input to restart or leave the program [closed]

I am making a program and want a simple echo asking if the user wants to Order again, or Leave the program. It's in Shell on Unix The program is simple echo and reading of variables of ordering food. ...
0
votes
1answer
239 views

Replace line in text file with user input at terminal

I am trying to prompt the user for two pieces of information: 1) The line number in the file to be changed 2) The value to change it to. My script so far: echo "Do you wish to enter a variable to ...
1
vote
1answer
490 views

How to use linebreak in read -p command while using variables in prompt string

I want to have a line break after prompt while using the cowsay function in the prompt : read -p "$(cowsay "do you know this word?") \n" answer there are multiple answers to this problem : 1)https:/...
0
votes
1answer
240 views

Move alias command to the background when password is requested

I prepared an alias to start my tightvnc viewer: alias vnc='/usr/bin/xtightvncviewer MOC' It worked. It asked me for the password and ran the vnc. But it prevented to put next commands in the same ...
2
votes
1answer
367 views

Pausing in GNU parallel and waiting for character

I would like the timing pause to be replaced with the equivalent of a getchar() in a GNU parallel execution: parallel -j2 --halt 2 ::: 'sleep 5m; return 1' './runMe' However the following does not ...
3
votes
4answers
13k views

How can I enable/disable the synaptics touchpad in Debian 9 with libinput?

I recently upgraded from Debian 8, to Debian 9 stretch. Apparently they no longer utilize synaptics /synclient to control touch-pad input. What I am looking for is a simple command to enable or ...
1
vote
1answer
6k views

Automatically input “yes” on the bash file [closed]

Slurm is workload manager. There are two kinds of modes to run job, interactive(srun) and batch mode(sbatch). When using interactive mode, one needs to leave the terminal open which may lead extra ...
4
votes
2answers
1k views

Wait for a process to finish OR for the user to press a key

I need two ways to terminate a part of my bash script. Either a counter reaches a predefined number, or the user manually forces the script to continue with whatever the value the counter currently ...
6
votes
1answer
2k views

How to signal end-of-input to “read -N”?

I've been trying to figure out why I get a literal end-of-transmission character (EOT, ASCII code 4) in my variable if I read Ctrl+D with read -N 1 in bash and ksh93. I'm aware of the distinction ...
1
vote
2answers
2k views

Bash function assign value to passed parameter

I've got the following situation: I'm writing a script that will read its parameters either from a config file (if exists and parameter present) or asks the user to input said parameter if it's not ...
3
votes
1answer
38k views

Bash script - Automatically enter user input (password of keystore)

I know this has been asked before but almost only workarounds have been provided. None that solved my problem just yet. I'm trying to create my own .sh file which will generate an apk. After using ...
9
votes
3answers
10k views

How to read the user input line by line until Ctrl+D and include the line where Ctrl+D was typed

This script takes the user input line after line, and executes myfunction on every line #!/bin/bash SENTENCE="" while read word do myfunction $word" done echo $SENTENCE To stop the input, the ...
2
votes
1answer
775 views

Script using user input to calculate old date

I have numerous of log files that I have to move from a production directory into an archive directory. I need to move them by creation date. Files from January 2016 go into an archive directory ...
0
votes
1answer
77 views

read 1 or several lines in bash - make it work when pasting (in addition to typing manually)

I read multiple answers with varying complexities. Most are working well when the input is typed manually. For example: https://stackoverflow.com/a/20913871/1841533 . Here is my sample code, very ...
1
vote
1answer
55 views

Python `read -n1 var`?

Is there a Python 3 module that allows to input a single character, without having to press Enter afterwards? Like Bash's read -n1 var?
-1
votes
1answer
2k views

Bash script to add or subtract two numbers from user input [duplicate]

I am very new to Linux and am taking a course in it. Very excited to learn more. I am working on a script that asks user for two numbers, then asks whether user wants to add or subtract. I failed the ...
0
votes
2answers
543 views

pausing a loop in AIX to wait for user input

I'm searching for a scripting mechanism that can realize the following idea. Loop over a list and stop/wait on "read x" until the next input from a user. I know the following script is not working! As ...
1
vote
0answers
15 views

Configuring an alert when a program tries to interact with the user

Most programs in *nix-land take their options via the command line or through a configuration file. However, there are a few programs that do not have any such option, and will resort to interacting ...
1
vote
1answer
531 views

Block user input on interactive shell using “cat /dev/ttyS0”

I created an update routine for my device. The update process can be started using the serial console, SSH, telnet, a webserver or a REST API. Once the update started, I want to block all user input ...
2
votes
2answers
10k views

Inputting user input automatically through bash script? [duplicate]

I am creating a bash script which creates a user and sets a password. When the command "passwd user" is run it requires the user to enter a password and stops my script. Is there any way to fulfill ...
3
votes
1answer
647 views

How can you get the current terminal line (the one that is still editable by the user)?

I need a way to use the current line which the users typed into as variable for a shell function. my current code, which can be called by ctrl+r zle -N search bindkey "^R" search search () { read ...
9
votes
4answers
10k views

How to read user input from a pipe?

Let's assume I have a file named confirmation.sh with the following content: #!/bin/bash echo -n "Are you sure [Y/n]? " read line case "$line" in n|N) echo "smth" ;; y|Y) echo "smth" ...
1
vote
1answer
1k views

Shell script to backup VMware VM's, exporting each VM to a list then asking user intput

What I'm Trying To Accomplish: Get list of Virtual Machines ".vmx" file and place in variables Give the user and choice of which VM to backup Use "ovftool" to produce an export of the chosen VM to a ...
0
votes
2answers
1k views

How to create as many variables as needed from shell script(bash)?

I'm making a script for monitoring some user processes with Upstart but, since its for the company I work for, they asked me to do it generic...how's so? Well, the number of processes being monitored ...
1
vote
0answers
154 views

Decreasing mouse sensitivity at kernel level

I have developed a custom-GUI Server, which runs on virtual console of Linux.For mouse-handling purpose, it reads the mouse device file /dev/input/mice and retrieves the event data and updates the ...
16
votes
3answers
53k views

How to take 'password' like input in shell script? [duplicate]

Possible Duplicate: How to hide commands typed in a Linux shell? Reading passwords without showing on screen in Bash Scripts I would like to take a password as input, but I want user to be able ...
9
votes
2answers
4k views

Requesting user input while reading file line by line

For class I need to write a Bash script that will take the output from ispell and when I try and request user input inside the while loop it just saves the next line of the file as the user input. ...
1
vote
1answer
4k views

Capture user input while doing other things

Is there a way to have the output of a subprocess (something other than 'sleep' below) be dovetailed with the output from a foreground command-loop? For example: while true do echo "updating ...