Questions tagged [user-input]

53 questions
21
votes
3 answers

How to take 'password' like input in shell script?

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 to enter it just like other utilities handle it i.e.…
mtk
  • 26,802
  • 35
  • 91
  • 130
10
votes
2 answers

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. How could I go about requesting user input in the…
Steven10172
  • 203
  • 2
  • 5
10
votes
4 answers

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" ;; esac and I want to run this script in…
Igor Timoshenko
  • 203
  • 1
  • 2
  • 5
9
votes
3 answers

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 has to press [ENTER] and then Ctrl+D. How can…
user123456
  • 4,758
  • 11
  • 52
  • 78
8
votes
2 answers

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 in the GUI to ask the user for input?
JoBe
  • 387
  • 5
  • 16
7
votes
4 answers

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 disable touch-pad functionality on demand, with…
bitbox
  • 131
  • 1
  • 1
  • 5
6
votes
1 answer

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 between the end-of-transmission character and the…
Kusalananda
  • 320,670
  • 36
  • 633
  • 936
5
votes
4 answers

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/executed. Having all commands on a single line works…
pLumo
  • 22,231
  • 2
  • 41
  • 66
5
votes
2 answers

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 jarsigner it asks for a password of my keystore. Now…
Ivaro18
  • 151
  • 1
  • 1
  • 5
4
votes
1 answer

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?
Nestor
  • 41
  • 1
4
votes
2 answers

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 single key and sets the variable to y if the key…
Trey
  • 292
  • 2
  • 9
4
votes
2 answers

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 has. Specifically - I'm listing USB drives. If…
unfa
  • 1,715
  • 3
  • 23
  • 34
4
votes
1 answer

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 str; fc -ln -30 | grep $(printf "%q\n"…
3
votes
1 answer

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…
Grunwalski
  • 133
  • 3
2
votes
2 answers

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: I've been using echo and basing it off of my…
user426441
  • 21
  • 1
1
2 3 4