Sponsored Content
Top Forums Shell Programming and Scripting Checking the user input in perl for characters and length Post 302997126 by Aia on Monday 8th of May 2017 10:37:16 AM
Old 05-08-2017
Code:
#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my @phr = qw(acg acc aca caa); # used on method 1

my (%phrhash, %reahash);
@phrhash{@phr} = ('Phr') x @phr; # method 1
@reahash{'gaa', 'gac'} = qw(Rea Rea); # method 2

print Dumper \%phrhash;
print Dumper \%reahash;

Output:

Code:
perl test.pl
$VAR1 = {
          'aca' => 'Phr',
          'caa' => 'Phr',
          'acg' => 'Phr',
          'acc' => 'Phr'
        };
$VAR1 = {
          'gaa' => 'Rea',
          'gac' => 'Rea'
        };

This User Gave Thanks to Aia For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies

2. Shell Programming and Scripting

Disallowing certain characters from user input

Hey, I've create a custom useradd script, and I don't want the person creating the user to be able to put comma's in any of the input fields, because it could corrupt the /etc/passwd file. I don't care what other characters they put in there, so is there a way I can just check all the input... (1 Reply)
Discussion started by: paqman
1 Replies

3. AIX

Is the Length of User ID for AIX Limit to 8 Characters?

Hi, I'm using AIX version 5.3 currently. I'm trying to create a user id, e.g. andyleong, which the system prompted the length is too long. 1. I would like to know is that the length of user id is limited to maximum 8 characters for AIX. 2. Is it apply to all versions of AIX? If no... (2 Replies)
Discussion started by: meihua_t
2 Replies

4. Shell Programming and Scripting

exit script if user input not four characters

#!/usr/bin/bash ###script to input four characters. wxyz echo "input first string" read instring1 echo "input second string" read instring2 ## echo "first string is:" $instring1 echo "second string is:" $instring2 ##IF instring1 or instring2 are NOT 4 characters (xxxx) , exit 1. ##how?? ... (2 Replies)
Discussion started by: ajp7701
2 Replies

5. Programming

Checking columns in SQL, comparing user input and sizes.

I'm writing a KSH shell script that's using SQL though DB2. If I have a table defined and populated db2 "create table tb(num int,letter char(4))" db2 "insert into tb values(111,a) db2 "insert into tb values(112,b) db2 "insert into tb values(111,c) How can I check if a letter user... (0 Replies)
Discussion started by: busdude
0 Replies

6. Shell Programming and Scripting

User input - Perl need Help

If I want all user input to start with " : " if not display error or what I asking is how to do if statement that control a first letter of string that we want to start with. and not worry about the rest Thank (1 Reply)
Discussion started by: guidely
1 Replies

7. Shell Programming and Scripting

user input in perl?

Please tell me how to write a perl script that asks the user to enter words and that passes them to a variable. In bash, the "read" command would achieve such user interaction. #!/bin/bash read -p "Enter files: " vFiles However, I am looking for perl version of something equivalent... (2 Replies)
Discussion started by: LessNux
2 Replies

8. Shell Programming and Scripting

TCSH user input error checking

This was taken down recently because it appeared to be homework, but it isn't. It's for a script I am working on at work. Thanks for the help. How do you check that user inputs (arguments 1 and 2) are both numbers and are at least 5 digits in length? (2 Replies)
Discussion started by: thibodc
2 Replies

9. Shell Programming and Scripting

User input in perl code

Hello friends . I am newbie to perl scripting but still managed to write a code but i am stuck at a place where i need help . Below is the code and can someone help me in taking user input for changing the font size for a html table .Thank you in advance #!/bin/ksh echo " Enter the Directory... (4 Replies)
Discussion started by: ajayram_arya
4 Replies

10. Shell Programming and Scripting

Perl to read user input

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
REXECD(8)						      System Manager's Manual							 REXECD(8)

NAME
rexecd - remote execution server SYNOPSIS
/usr/libexec/rexecd DESCRIPTION
Rexecd is the server for the rexec(3) routine. The server provides remote execution facilities with authentication based on user names and passwords. Rexecd listens for service requests at the port indicated in the ``exec'' service specification; see services(5). When a service request is received the following protocol is initiated: 1) The server reads characters from the socket up to a null (`') byte. The resultant string is interpreted as an ASCII number, base 10. 2) If the number received in step 1 is non-zero, it is interpreted as the port number of a secondary stream to be used for the stderr. A second connection is then created to the specified port on the client's machine. 3) A null terminated user name of at most 16 characters is retrieved on the initial socket. 4) A null terminated, unencrypted password of at most 16 characters is retrieved on the initial socket. 5) A null terminated command to be passed to a shell is retrieved on the initial socket. The length of the command is limited by the upper bound on the size of the system's argument list. 6) Rexecd then validates the user as is done at login time and, if the authentication was successful, changes to the user's home direc- tory, and establishes the user and group protections of the user. If any of these steps fail the connection is aborted with a diag- nostic message returned. 7) A null byte is returned on the initial socket and the command line is passed to the normal login shell of the user. The shell inherits the network connections established by rexecd. DIAGNOSTICS
Except for the last one listed below, all diagnostic messages are returned on the initial socket, after which any network connections are closed. An error is indicated by a leading byte with a value of 1 (0 is returned in step 7 above upon successful completion of all the steps prior to the command execution). ``username too long'' The name is longer than 16 characters. ``password too long'' The password is longer than 16 characters. ``command too long '' The command line passed exceeds the size of the argument list (as configured into the system). ``Login incorrect.'' No password file entry for the user name existed. ``Password incorrect.'' The wrong was password supplied. ``No remote directory.'' The chdir command to the home directory failed. ``Try again.'' A fork by the server failed. ``<shellname>: ...'' The user's login shell could not be started. This message is returned on the connection associated with the stderr, and is not preceded by a flag byte. SEE ALSO
rexec(3) BUGS
Indicating ``Login incorrect'' as opposed to ``Password incorrect'' is a security breach which allows people to probe a system for users with null passwords. A facility to allow all data and password exchanges to be encrypted should be present. 4.2 Berkeley Distribution November 16, 1996 REXECD(8)
All times are GMT -4. The time now is 05:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy