11-28-2012
Thanks for this code.
Although it's not quite what I'm looking for it's definitely a more portable way of doing things.
The code you proposed results in the following output:
Please enter the username you would like to add to LDAP (user1):
The code I use in BASH 4 results in the following output:
Please enter the username you would like to add: user1
The user name is populated on the editable line already so I can hit enter and accept or hit backspace and make the changes I want.
It's really semantics but It can save a few key strokes.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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)
Discussion started by: sdsd
6 Replies
2. UNIX for Dummies Questions & Answers
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)
Discussion started by: krishnampkkm
4 Replies
3. Shell Programming and Scripting
Hi all, I currently have a script which uses read -p for user interaction. e.g.
read -p "New user? " user
Is it possible to have it so if the user enters nothing and just presses return it can resort to a specified value instead?
Thanks! :) (5 Replies)
Discussion started by: JayC89
5 Replies
4. Shell Programming and Scripting
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)
Discussion started by: dropkick888
8 Replies
5. Shell Programming and Scripting
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)
Discussion started by: PDManc
2 Replies
6. Shell Programming and Scripting
I am starting to learn how to use bash and I would like the script to do the following:
Asks the user for his/her name
Asks the user for one number
Asks the user for another number
Then it adds the two numbers,
Also multiply the two numbers
I have the part where you get the name, and I... (3 Replies)
Discussion started by: boyboy1212
3 Replies
7. Shell Programming and Scripting
Hi
I am new to writing script and want to use a Bash Piped while-read and read from user input.
if something happens on server.log then do while loop or if something happend on user input then do while loop.
Pseudocode something like:
tail -n 3 -f server.log | while read serverline || read... (8 Replies)
Discussion started by: MyMorris
8 Replies
8. Shell Programming and Scripting
Hello.
I am running 2 scripts : script_1 and script_2
These scripts are run as root
Script 2 contains :
#!/bin/bash
#
# ~/bin/script_2
#
E_BAD_PARAM=115
#
date2stamp () {
date --date "$1" +%Y-%m-%d___%H:%M:%S
}
#
USER_NAME=$1
NB_PARAM=$#
PARAM0=$0 (2 Replies)
Discussion started by: jcdole
2 Replies
9. Shell Programming and Scripting
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)
Discussion started by: cmccabe
4 Replies
10. Shell Programming and Scripting
I'm having an issue with bash read input when using a case statement.
The script halts and doesn't read the input on the first loop. if I hit enter then the scripts starts to respond as expected. Need some help here.
defaultans=8hrs
read -e -i $defaultans -p "${bldwht}How long would you like... (5 Replies)
Discussion started by: woodson2
5 Replies
LUA(1) General Commands Manual LUA(1)
NAME
lua - Lua interpreter
SYNOPSIS
lua [ options ] [ script [ args ] ]
DESCRIPTION
lua is the stand-alone Lua interpreter. It loads and executes Lua programs, either in textual source form or in precompiled binary form.
(Precompiled binaries are output by luac, the Lua compiler.) lua can be used as a batch interpreter and also interactively.
The given options (see below) are executed and then the Lua program in file script is loaded and executed. The given args are available to
script as strings in a global table named arg. If these arguments contain spaces or other characters special to the shell, then they
should be quoted (but note that the quotes will be removed by the shell). The arguments in arg start at 0, which contains the string
'script'. The index of the last argument is stored in arg.n. The arguments given in the command line before script, including the name of
the interpreter, are available in negative indices in arg.
At the very start, before even handling the command line, lua executes the contents of the environment variable LUA_INIT, if it is defined.
If the value of LUA_INIT is of the form '@filename', then filename is executed. Otherwise, the string is assumed to be a Lua statement and
is executed.
Options start with '-' and are described below. You can use '--' to signal the end of options.
If no arguments are given, then -v -i is assumed when the standard input is a terminal; otherwise, - is assumed.
In interactive mode, lua prompts the user, reads lines from the standard input, and executes them as they are read. If a line does not
contain a complete statement, then a secondary prompt is displayed and lines are read until a complete statement is formed or a syntax
error is found. So, one way to interrupt the reading of an incomplete statement is to force a syntax error: adding a ';' in the middle of
a statement is a sure way of forcing a syntax error (except inside multiline strings and comments; these must be closed explicitly). If a
line starts with '=', then lua displays the values of all the expressions in the remainder of the line. The expressions must be separated
by commas. The primary prompt is the value of the global variable _PROMPT, if this value is a string; otherwise, the default prompt is
used. Similarly, the secondary prompt is the value of the global variable _PROMPT2. So, to change the prompts, set the corresponding
variable to a string of your choice. You can do that after calling the interpreter or on the command line (but in this case you have to be
careful with quotes if the prompt string contains a space; otherwise you may confuse the shell.) The default prompts are "> " and ">> ".
OPTIONS
- load and execute the standard input as a file, that is, not interactively, even when the standard input is a terminal.
-e stat
execute statement stat. You need to quote stat if it contains spaces, quotes, or other characters special to the shell.
-i enter interactive mode after script is executed.
-l name
call require('name') before executing script. Typically used to load libraries.
-v show version information.
SEE ALSO
luac(1)
http://www.lua.org/
DIAGNOSTICS
Error messages should be self explanatory.
AUTHORS
R. Ierusalimschy, L. H. de Figueiredo, and W. Celes
$Date: 2010/10/31 11:16:49 $ LUA(1)