Sponsored Content
Top Forums Shell Programming and Scripting read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell Post 302281042 by pludi on Wednesday 28th of January 2009 05:11:35 AM
Old 01-28-2009
A (very) simple substitute would be
Code:
printf "Prompt: "
read command

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to request a "read" or "delivered" receipt for mails

Dears, I've written a script which allows me to send mails in different formats with different attaches. Now I still want to add a feature to this script. My users would like to be able to receive a "read" or "delivered" receipt for their mails. The script send mails on behalve of an specific... (1 Reply)
Discussion started by: plelie2
1 Replies

2. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

3. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

4. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

5. UNIX for Dummies Questions & Answers

the meaning of "!:*" in "alias foo 'command\!:*' filename"

Hi: How can I remove my own post? Thanks. (2 Replies)
Discussion started by: phil518
2 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Purpose of "read" and "$END$" in ksh ?

Hi, Could anyone please shed some light on the following script lines and what is it doing as it was written by an ex-administrator? cat $AMS/version|read a b verno d DBVer=$(/usr/bin/printf "%7s" $verno) I checked that the cat $AMS/version command returns following output: ... (10 Replies)
Discussion started by: dbadmin100
10 Replies

8. Shell Programming and Scripting

Read from "list1" and list matches in "list2"

I want to print any matching IP addresse in List1 with List 2; List 1 List of IP addresses; 161.85.58.210 250.57.15.129 217.23.162.249 74.76.129.101 30.221.177.237 3.147.200.59 170.58.142.64 127.65.109.33 150.167.242.146 223.3.20.186 25.181.180.99 2.55.199.32 (3 Replies)
Discussion started by: lewk
3 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. Shell Programming and Scripting

Failure: if grep "$Var" "$line" inside while read line loop

Hi everybody, I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o My code: #!/bin/sh set -e set -u export IFS= optl="Optl" LOCSTORCLI="/opt/lsi/storcli/storcli" ($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
Discussion started by: Subsonic66
5 Replies
Expect::Simple(3pm)					User Contributed Perl Documentation				       Expect::Simple(3pm)

NAME
Expect::Simple - wrapper around the Expect module SYNOPSIS
use Expect::Simple; my $obj = new Expect::Simple { Cmd => [ dmcoords => 'verbose=1', "infile=$infile"], Prompt => [ -re => 'dmcoords>:s+' ], DisconnectCmd => 'q', Verbose => 0, Debug => 0, Timeout => 100 }; $obj->send( $cmd ); print $obj->before; print $obj->after; print $obj->match_str, " "; print $obj->match_idx, " "; print $obj->error_expect; print $obj->error; $expect_object = $obj->expect_handle; DESCRIPTION
"Expect::Simple" is a wrapper around the "Expect" module which should suffice for simple applications. It hides most of the "Expect" machinery; the "Expect" object is available for tweaking if need be. Generally, one starts by creating an Expect::Simple object using new. This will start up the target program, and will wait until one of the specified prompts is output by the target. At that point the caller should send() commands to the program; the results are available via the before, after, match_str, and match_idx methods. Since Expect simulates a terminal, there will be extra " " characters at the end of each line in the result (on UNIX at least). This is easily fixed: ($res = $obj->before) =~ tr/ //d; @lines = split( " ", $res ); This is not done automatically. Exceptions will be thrown on error (match with "/Expect::Simple/"). Errors from Expect are available via the error_expect method. More human readable errors are available via the error method. The connection is automatically broken (by sending the specified disconnect command to the target) when the Expect::Simple object is destroyed. Methods new $obj = Expect::Simple->new( \%attr ); This creates a new object, starting up the program with which to communicate (using the Expect spawn method) and waiting for a prompt. The passed hash reference must contain at least the Prompt, DisconnectCmd, and Cmd elements. The available attributes are: Cmd Cmd => $command, Cmd => [ $command, $arg1, $arg2, ... ], The command to which to connect. The passed command may either be a scalar or an array. Prompt This specifies one or more prompts to scan for. For a single prompt, the value may be a scalar; for more, or for matching of regular expressions, it should be an array reference. For example, Prompt => 'prompt1> ', Prompt => [ 'prompt1> ', 'prompt2> ', -re => 'promptd+>s+' ] All prompts are taken literally, unless immediately preceded by a "-re" flag, in which case they are regular expressions. DisconnectCmd This is the command to be sent to the target program which will cause it to exit. RawPty If set, then underlying Expect object's pty mode is set to raw mode (see Expect::raw_pty()). Timeout The time in seconds to wait until giving up on the target program responding. This is used during program startup and when any commands are sent to the program. It defaults to 1000 seconds. Debug The value is passed to Expect via its debug method. Verbose This results in various messages printed to the STDERR stream. If greater than 3, it turns on Expect's logging to STDOUT (via the log_stdout Expect method. send $obj->send( $cmd ); $obj->send( @cmds ); Send one or more commands to the target. After each command is sent, it waits for a prompt from the target. Only the output resulting from the last command is available via the after, before, etc. methods. match_idx This returns a unary based index indicating which prompt (in the list of prompts specified via the "Prompt" attribute to the new method) was received after the last command was sent. It will be undef if none was returned. match_str This returns the prompt which was matched after the last command was sent. before This returns the string received before the prompt. If no prompt was seen, it returns all output accumulated. This is usually what the caller wants to parse. Note that the first line will (usually) be the command that was sent to the target, because of echoing. Check this out to be sure! after This returns the 'after' string. Please read the Expect docs for more enlightenment. error This returns a cleaned up, more humanly readable version of the errors from Expect. It'll be undef if there was no error. error_expect This returns the original Expect error. expect_handle This returns the Expect object, in case further tweaking is necessary. BUGS
If the command to be run does not exist (or not in the current execution path), it's quite possible that the new method will not throw an exception. It's up to the caller to make sure that the command will run! There's no known workaround for this. LICENSE
This software is released under the GNU General Public License. You may find a copy at http://www.fsf.org/copyleft/gpl.html AUTHOR
Diab Jerius (djerius@cpan.org) perl v5.12.4 2008-05-06 Expect::Simple(3pm)
All times are GMT -4. The time now is 04:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy