Sponsored Content
Top Forums Shell Programming and Scripting Giving "read" from standard input a timeout. Post 65227 by Perderabo on Thursday 3rd of March 2005 04:02:00 PM
Old 03-03-2005
rello, what system are you using? If you have the line program, try:
ans=$(line)
rather than
read ans
 

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. Shell Programming and Scripting

Breaking input with "read" command

In this post, Perderabo's script says echo 05/06/25 14:15:56 | IFS=" /:" read Y1 M1 D1 h1 m1 s1 which, if I am not wrong, will break the input into Y1, M1 et al. I tried the following in my code #! /bin/ksh # per.sh typeset -R2 HOUR=00 typeset -R2 MIN=00 typeset -R2 SEC=00 ... (2 Replies)
Discussion started by: vino
2 Replies

3. Shell Programming and Scripting

check input = "empty" and "numeric"

Hi how to check input is "empty" and "numeric" in ksh? e.g: ./myscript.ksh k output show: invalid number input ./myscript.ksh output show: no input ./myscript.ksh 10 output show: input is numeric (6 Replies)
Discussion started by: geoffry
6 Replies

4. Shell Programming and Scripting

How to timeout the "read" command

I have a script that at some point will ask the interactive user a question: #!/bin/ksh echo "What is your access code?" read ans ... Sometimes this script is run by other scripts and there are no interactive users. The script then hangs on the "read" command, waiting for a user response... (5 Replies)
Discussion started by: rm-r
5 Replies

5. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

6. Shell Programming and Scripting

Manipulating input into the shell "read" command

Hi All I have a migration program that creates directories based on dates, e.g 20090714 20090812 etc.. Based on their requirements, the user will select the directory they want to perform an action on. Currently, this is a snippet of the code I use no_of_versions=`ls | wc -l` if... (2 Replies)
Discussion started by: kingpin2502
2 Replies

7. 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

8. 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

9. 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

10. 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
PAM(3pm)						User Contributed Perl Documentation						  PAM(3pm)

NAME
Authen::PAM - Perl interface to PAM library SYNOPSIS
use Authen::PAM; $res = pam_start($service_name, $pamh); $res = pam_start($service_name, $user, $pamh); $res = pam_start($service_name, $user, &my_conv_func, $pamh); $res = pam_end($pamh, $pam_status); $res = pam_authenticate($pamh, $flags); $res = pam_setcred($pamh, $flags); $res = pam_acct_mgmt($pamh, $flags); $res = pam_open_session($pamh, $flags); $res = pam_close_session($pamh, $flags); $res = pam_chauthtok($pamh, $flags); $error_str = pam_strerror($pamh, $errnum); $res = pam_set_item($pamh, $item_type, $item); $res = pam_get_item($pamh, $item_type, $item); if (HAVE_PAM_ENV_FUNCTIONS()) { $res = pam_putenv($pamh, $name_value); $val = pam_getenv($pamh, $name); %env = pam_getenvlist($pamh); } if (HAVE_PAM_FAIL_DELAY()) { $res = pam_fail_delay($pamh, $musec_delay); $res = pam_set_item($pamh, PAM_FAIL_DELAY(), &my_fail_delay_func); } DESCRIPTION
The Authen::PAM module provides a Perl interface to the PAM library. The only difference with the standard PAM interface is that instead of passing a pam_conv struct which has an additional context parameter appdata_ptr, you must only give an address to a conversation function written in Perl (see below). If you want to pass a NULL pointer as a value of the $user in pam_start use undef or the two-argument version. Both in the two and the three-argument versions of pam_start a default conversation function is used (Authen::PAM::pam_default_conv). The $flags argument is optional for all functions which use it except for pam_setcred. The $pam_status argument is also optional for pam_end function. Both of these arguments will be set to 0 if not given. The names of some constants from the PAM library have changed over the time. You can use any of the known names for a given constant although it is advisable to use the latest one. When this module supports some of the additional features of the PAM library (e.g. pam_fail_delay) then the corresponding HAVE_PAM_XXX constant will have a value 1 otherwise it will return 0. For compatibility with older PAM libraries I have added the constant HAVE_PAM_ENV_FUNCTIONS which is true if your PAM library has the functions for handling environment variables (pam_putenv, pam_getenv, pam_getenvlist). Object Oriented Style If you prefer to use an object oriented style for accessing the PAM library here is the interface: use Authen::PAM qw(:constants); $pamh = new Authen::PAM($service_name); $pamh = new Authen::PAM($service_name, $user); $pamh = new Authen::PAM($service_name, $user, &my_conv_func); ref($pamh) || die "Error code $pamh during PAM init!"; $res = $pamh->pam_authenticate($flags); $res = $pamh->pam_setcred($flags); $res = $pamh->pam_acct_mgmt($flags); $res = $pamh->pam_open_session($flags); $res = $pamh->pam_close_session($flags); $res = $pamh->pam_chauthtok($flags); $error_str = $pamh->pam_strerror($errnum); $res = $pamh->pam_set_item($item_type, $item); $res = $pamh->pam_get_item($item_type, $item); $res = $pamh->pam_putenv($name_value); $val = $pamh->pam_getenv($name); %env = $pamh->pam_getenvlist; The constructor new will call the pam_start function and if successfull will return an object reference. Otherwise the $pamh will contain the error number returned by pam_start. The pam_end function will be called automatically when the object is no longer referenced. Examples Here is an example of using PAM for changing the password of the current user: use Authen::PAM; $login_name = getpwuid($<); pam_start("passwd", $login_name, $pamh); pam_chauthtok($pamh); pam_end($pamh); or the same thing but using OO style: $pamh = new Authen::PAM("passwd", $login_name); $pamh->pam_chauthtok; $pamh = 0; # Force perl to call the destructor for the $pamh Conversation function format When starting the PAM the user must supply a conversation function. It is used for interaction between the PAM modules and the user. The argument of the function is a list of pairs ($msg_type, $msg) and it must return a list with the same number of pairs ($resp_retcode, $resp) with replies to the input messages. For now the $resp_retcode is not used and must be always set to 0. In addition the user must append to the end of the resulting list the return code of the conversation function (usually PAM_SUCCESS). If you want to abort the conversation function for some reason then just return an error code, normally PAM_CONV_ERR. Here is a sample form of the PAM conversation function: sub my_conv_func { my @res; while ( @_ ) { my $msg_type = shift; my $msg = shift; print $msg; # switch ($msg_type) { obtain value for $ans; } push @res, (0,$ans); } push @res, PAM_SUCCESS(); return @res; } More examples can be found in the Authen::PAM:FAQ. COMPATIBILITY
The following constant names: PAM_AUTHTOKEN_REQD, PAM_CRED_ESTABLISH, PAM_CRED_DELETE, PAM_CRED_REINITIALIZE, PAM_CRED_REFRESH are used by some older version of the Linux-PAM library and are not exported by default. If you really want them, load the module with use Authen::PAM qw(:DEFAULT :old); This module still does not support some of the new Linux-PAM functions such as pam_system_log. SEE ALSO
PAM Application developer's Manual, Authen::PAM::FAQ AUTHOR
Nikolay Pelov <NIKIP at cpan.org> COPYRIGHT
Copyright (c) 1998-2005 Nikolay Pelov. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-11-15 PAM(3pm)
All times are GMT -4. The time now is 02:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy