Questions tagged [user-input]
The user-input tag has no usage guidance.
53
questions
1
vote
0
answers
19
views
How do I request a user input with GUI from script running as root by modern initialization system?
I have Systemd service of type "oneshot" to be launched by Udev upon a device insertion. Service is launching shell script as root. The script needs user input in order to do it's job as ...
0
votes
0
answers
15
views
Typing into android-studio over X Forwarding sends text into the console instead
I am running android-studio from the command line on another machine on my home network. I am connecting to that machine using:
ssh -C -X machine-name.local
Keypresses do not seem to be registered ...
0
votes
2
answers
298
views
Source script with user input
I have a script that is something like
#!/bin/bash
echo -n "User: "
read -e username
echo -n "Password: "
read -es password
export http_proxy="http://$username:$password@...
4
votes
1
answer
448
views
Put a specific file in every Unix user's home directory when they're created and added to a particular group
How can I set up my Solaris system so that every time a user is created and assigned to a specific group, a specific file is placed in that user's home directory?
1
vote
1
answer
326
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 ...
0
votes
1
answer
1k
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 ...
0
votes
1
answer
430
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 "" )...
1
vote
2
answers
2k
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 ...
1
vote
1
answer
1k
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 ...
1
vote
1
answer
1k
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. ...
8
votes
2
answers
5k
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
2
answers
502
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
1
answer
55
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
1
answer
2k
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
1
answer
1k
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 ...
4
votes
2
answers
2k
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
1
answer
3k
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... ...
2
votes
2
answers
625
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
1
answer
383
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
4
answers
2k
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
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 ...
0
votes
1
answer
26
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
1
answer
881
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 ...
5
votes
4
answers
12k
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
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 ...
2
votes
2
answers
8k
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
1
answer
39
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
1
answer
382
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 ...
3
votes
1
answer
2k
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
1
answer
534
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
1
answer
513
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 ...
7
votes
4
answers
19k
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 ...
2
votes
1
answer
14k
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
2
answers
3k
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
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 ...
1
vote
2
answers
4k
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 ...
5
votes
2
answers
56k
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
3
answers
21k
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
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 ...
0
votes
1
answer
156
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
1
answer
70
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
1
answer
5k
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
2
answers
715
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
1
answer
774
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
2
answers
13k
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 ...
4
votes
1
answer
2k
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 ...
10
votes
4
answers
13k
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
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 ...
0
votes
2
answers
2k
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
0
answers
243
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 ...