Questions tagged [user-input]

The tag has no usage guidance.

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

Read file from user input with a list of prefixes, then call file with prefixes in while loops

I am trying to direct user input file into while loop, but kept on failing when ran the script. The user input file genelist contained a list of numbers where I have been using as prefixes of my other ...
user avatar
  • 165
0 votes
0 answers
35 views

A loop to work up to 8 times only accepting 4 numbers as variables

I want to create a loop to ask someone to input a number (or range of numbers) up to a maximum of 8 numbers and the numbers must be 4 chars like below:- i.e 0001 0002 0030 0100 0900 0999 1016 1082 I ...
user avatar
  • 11
0 votes
1 answer
282 views

How can I take multiple inputs from a user and convert to a string that looks up values and adds them to a variable?

I have a script that takes input from a user (options 1, 2, 3, etc.) to choose files to deploy to a remote server. Instead of the user running this script multiple times, I would like for them to be ...
user avatar
0 votes
1 answer
180 views

why perl's if condition is satisfying empty string?

The below code works fine, except for the part the STDIN takes an empty value also and goes to first selection "print "Selected Y \n";". If I use && $check ne "" )...
user avatar
  • 882
1 vote
2 answers
445 views

Read from terminal without waiting for [ENTER]

I'm sorry to bother you with such silly questions, but I recently started working with the Linux terminal and when I was reading a paper about the command stty I found the following question: ¿How ...
user avatar
1 vote
1 answer
354 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 ...
user avatar
1 vote
1 answer
350 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. ...
user avatar
  • 513
6 votes
2 answers
2k 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 ...
user avatar
  • 327
2 votes
2 answers
253 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: ...
user avatar
0 votes
1 answer
30 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/,/...
user avatar
-1 votes
1 answer
984 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 ...
user avatar
2 votes
1 answer
425 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 ...
user avatar
3 votes
1 answer
943 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 ...
user avatar
  • 272
0 votes
1 answer
1k 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... ...
user avatar
2 votes
2 answers
301 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.
user avatar
0 votes
1 answer
166 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 ...
user avatar
2 votes
4 answers
956 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. ...
user avatar
0 votes
2 answers
1k 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 ...
user avatar
0 votes
1 answer
22 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 ...
user avatar
  • 379
-1 votes
1 answer
559 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 ...
user avatar
3 votes
4 answers
8k 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/...
user avatar
  • 20.6k
0 votes
1 answer
1k 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 ...
user avatar
1 vote
2 answers
5k 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 ...
user avatar
0 votes
1 answer
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. ...
user avatar
  • 31
0 votes
1 answer
329 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 ...
user avatar
  • 103
3 votes
1 answer
1k 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:/...
user avatar
0 votes
1 answer
311 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 ...
user avatar
  • 600
2 votes
1 answer
455 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 ...
user avatar
6 votes
4 answers
17k 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 ...
user avatar
  • 111
2 votes
1 answer
11k 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 ...
user avatar
4 votes
2 answers
2k 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 ...
user avatar
  • 1,503
6 votes
1 answer
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 ...
user avatar
  • 267k
1 vote
2 answers
3k 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 ...
user avatar
  • 111
5 votes
2 answers
51k 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 ...
user avatar
  • 151
9 votes
3 answers
16k 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 ...
user avatar
  • 4,248
2 votes
1 answer
1k 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 ...
user avatar
0 votes
1 answer
114 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 ...
user avatar
1 vote
1 answer
60 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?
user avatar
  • 710
-1 votes
1 answer
4k 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 ...
user avatar
  • 11
0 votes
2 answers
639 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 ...
user avatar
1 vote
0 answers
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 ...
user avatar
  • 2,165
1 vote
1 answer
650 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 ...
user avatar
  • 1,810
2 votes
2 answers
11k 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 ...
user avatar
4 votes
1 answer
1k 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 ...
user avatar
10 votes
4 answers
12k 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" ...
user avatar
1 vote
1 answer
2k 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 ...
user avatar
0 votes
2 answers
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 ...
user avatar
1 vote
0 answers
201 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 ...
user avatar
19 votes
3 answers
71k 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 ...
user avatar
  • 24.1k
9 votes
2 answers
5k 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. ...
user avatar