Read user input from /dev/tty, to avoid accidentally reading input from the pipe or file instead. /dev/tty will always be the current terminal, if any.
These 2 Users Gave Thanks to Corona688 For This Post:
Hi,
The gcc compiler has warned about using gets(), so I've been trying my hand at getline.
Problem is that I've been able to read from a file, but what I really need is to read from a user's input.
I want to use getline like a scanf() command, but I can't figure what to substitute for the fp... (6 Replies)
Hiii
I wanna a read a line of text from standard input. The user enter data like this way
name phone_no month1_salary month2_salary
that is user enter the name ,phone no and salary of 2 months in a single line by giving spaces. I wanna add the 3rd and 4th fields ...ie add both... (4 Replies)
I am trying to script simply data transfer. I would like to have the user input the source "SRC" (/Volumes/DriveName/Users/johnq123) and then name the directory that the copied information will go to, "DST" . put I can't get it to work -
#!/bin/bash
... (8 Replies)
Hi All,
I am working on a script which requires an input from user within one 1 min.
So if the user gives the required input within 1 min., it will execute on the basis of input provided by the user.Other wise it will execute on a default value(hard coded inside the script).
Now, I am... (19 Replies)
I need to write a bourne shell script (solaris 10) that accepts input from the user. The input will be a command- any command like ls/ pwd/ mv etc. After the input is read, the shell must execute the command supplied by the user.
I know we use read to play with user inputs. Just not sure how to... (2 Replies)
Below is a simple script to prompt for user input while suggesting an editable default value at the prompt:
shortname=user1
read -e -i $shortname -p "Please enter the username you would like to add: " input
USERNAME="${input:-$shortname}"
Please enter the username you would like to add:... (3 Replies)
I am creating a bash that uses perl . The below code closes before the input is entered. If I run the perl as a .pl it is fine. What am I doing wrong? Thank you :).
#!/bin/bash
cd 'C:\Users\cmccabe\Desktop\wget'
wget -O getCSV.txt http://xxx.xx.xxx.xxx/data/getCSV.csv
print... (4 Replies)
Hi,
i am working on one automation , for that i have writing one shell program that take user input in "while read line" block. but read command is taking value that is readed by While block.
while read line; do
command 1;
command 2
echo -n "Do you want to continute > "
read rsp... (2 Replies)
Hi,
This query is a part of a much more lengthy script.
I wish to look for all the files in a folder named "data" which in this case has two files i.e. plan.war and agent.properties. For all the files found under data I wish to ask the user as to where they wish copy the files to.
Below,... (14 Replies)
Discussion started by: mohtashims
14 Replies
LEARN ABOUT LINUX
getpass
GETPASS(3) Linux Programmer's Manual GETPASS(3)NAME
getpass - get a password
SYNOPSIS
#include <unistd.h>
char *getpass( const char *prompt);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
getpass():
Since glibc 2.2.2:
_BSD_SOURCE ||
(_XOPEN_SOURCE >= 500 ||
_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&
!(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
Before glibc 2.2.2: none
DESCRIPTION
This function is obsolete. Do not use it.
The getpass() function opens /dev/tty (the controlling terminal of the process), outputs the string prompt, turns off echoing, reads one
line (the "password"), restores the terminal state and closes /dev/tty again.
RETURN VALUE
The function getpass() returns a pointer to a static buffer containing (the first PASS_MAX bytes of) the password without the trailing new-
line, terminated by a null byte ('