Sponsored Content
Top Forums Shell Programming and Scripting Awk/shell question: Read from file and assign to variables. Post 302192765 by akbar on Wednesday 7th of May 2008 06:10:56 PM
Old 05-07-2008
Quote:
Originally Posted by jim mcnamara
how about
Code:
while read HOST PASS
do
      echo "HOST = $HOST  PASS = $PASS"
done < $PASSLIST

Excellent! Thank you.

akbar
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how can i read text file and assign its values to variables using shell

Hello, I have a cat.dat file, i would like shell to read each 3 lines and set this 3 lines to 3 different variables. my cat.dat is: 11 12 +380486461001 12 13 +380486461002 13 14 +380486461003 i want shell to make a loop and assign 1st line to student_id, 2nd line to... (4 Replies)
Discussion started by: rosalinda
4 Replies

2. Shell Programming and Scripting

How to read a file and assign variables to data?

Hi, I need a simple csh script to read a file containing data like this Buy Transactions : 175 Sell Transactions : 212 Server: sepo2 i want to read both field and its value and assign variables to each.. (2 Replies)
Discussion started by: pravsripad
2 Replies

3. Shell Programming and Scripting

How to read a delimited string and assign fields to incremented variables?

How can I read a string delimited on spaces and assign the fields to incremented variables. For example: Given $exts= txt dat mov I want to read in $exts and have "txt" "dat" and "mov" assigned to incremented variables like $ext1, $ext2, etc. I would like to do this in a loop so that I can... (4 Replies)
Discussion started by: runit
4 Replies

4. Shell Programming and Scripting

Read variables names from array and assign the values

Hi, I have requirement to assign values to variables which are created dynamically. Below is the code which i am using to achieve above requirement. #!/bin/ksh oIFS="$IFS"; IFS=',' STR_FAIL_PARENT_IF_FAILS="WF_F_P_IF_FAILS1,WF_F_P_IF_FAILS2,WF_F_P_IF_FAILS3" set -A... (1 Reply)
Discussion started by: tmalik79
1 Replies

5. Shell Programming and Scripting

Read record from the text file & assign those values to variables in the script

For eg: I have sample.txt file with 4 rows of record like: user1|password1 user2|password2 user3|password3 user4|password4 The username and password is sepsrated by '|' I want to get the 1st row value from the file and assign it to two different variables(username and password) in my... (1 Reply)
Discussion started by: priya001
1 Replies

6. Shell Programming and Scripting

Unable to read assign values to two variables in while loop

I am trying to read a input file which has two columns separated by space Input file server1 server2 server3 server4 server5 server6 When i execute the below while code it reads line by line and a and b variables are able to successfully fetch the values while read a b do echo "$a" echo... (5 Replies)
Discussion started by: chidori
5 Replies

7. Shell Programming and Scripting

Shell script to read a file and store in variables

I have a input file like this. Sample.txt 30 | TXDatacenter | TXBackupDC 10 | UKDatacenter | UKBackupDC 0 | NLDatacenter | NLBackupDC ...... ...... ...... I need to get these values in different variables like this. Load1=30 PriCenter1=TXDatacenter... (5 Replies)
Discussion started by: Visha
5 Replies

8. Shell Programming and Scripting

How to read a two files, line by line in UNIX script and how to assign shell variable to awk ..?

Input are file and file1 file contains store.bal product.bal category.bal admin.bal file1 contains flip.store.bal ::FFFF:BADC:CD28,::FFFF:558E:11C5,6,8,2,1,::FFFF:81C8:CA8B,::FFFF:BADC:CD28,1,0,0,0,::FFFF:81C8:11C5,2,1,0,0,::FFFF:81DC:3111,1,0,1,0 store.bal.... (2 Replies)
Discussion started by: veeruasu
2 Replies

9. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

10. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

I've got a file that looks like this (spaces before first entries intentional): 12345650-000005000GL140227 ANNUAL HELC FEE EN 22345650-000005000GL140227 ANNUAL HELC FEE EN 32345650-000005000GL140227 ANNUAL HELC FEE EN I want to read through the file line by line,... (6 Replies)
Discussion started by: Scottie1954
6 Replies
Net::POP3(3pm)						 Perl Programmers Reference Guide					    Net::POP3(3pm)

NAME
Net::POP3 - Post Office Protocol 3 Client class (RFC1939) SYNOPSIS
use Net::POP3; # Constructors $pop = Net::POP3->new('pop3host'); $pop = Net::POP3->new('pop3host', Timeout => 60); if ($pop->login($username, $password) > 0) { my $msgnums = $pop->list; # hashref of msgnum => size foreach my $msgnum (keys %$msgnums) { my $msg = $pop->get($msgnum); print @$msg; $pop->delete($msgnum); } } $pop->quit; DESCRIPTION
This module implements a client interface to the POP3 protocol, enabling a perl5 application to talk to POP3 servers. This documentation assumes that you are familiar with the POP3 protocol described in RFC1939. A new Net::POP3 object must be created with the new method. Once this has been done, all POP3 commands are accessed via method calls on the object. CONSTRUCTOR
new ( [ HOST ] [, OPTIONS ] 0 This is the constructor for a new Net::POP3 object. "HOST" is the name of the remote host to which an POP3 connection is required. "HOST" is optional. If "HOST" is not given then it may instead be passed as the "Host" option described below. If neither is given then the "POP3_Hosts" specified in "Net::Config" will be used. "OPTIONS" are passed in a hash like fashion, using key and value pairs. Possible options are: Host - POP3 host to connect to. It may be a single scalar, as defined for the "PeerAddr" option in IO::Socket::INET, or a reference to an array with hosts to try in turn. The "host" method will return the value which was used to connect to the host. ResvPort - If given then the socket for the "Net::POP3" object will be bound to the local port given using "bind" when the socket is created. Timeout - Maximum time, in seconds, to wait for a response from the POP3 server (default: 120) Debug - Enable debugging information METHODS
Unless otherwise stated all methods return either a true or false value, with true meaning that the operation was a success. When a method states that it returns a value, failure will be returned as undef or an empty list. auth ( USERNAME, PASSWORD ) Attempt SASL authentication. user ( USER ) Send the USER command. pass ( PASS ) Send the PASS command. Returns the number of messages in the mailbox. login ( [ USER [, PASS ]] ) Send both the USER and PASS commands. If "PASS" is not given the "Net::POP3" uses "Net::Netrc" to lookup the password using the host and username. If the username is not specified then the current user name will be used. Returns the number of messages in the mailbox. However if there are no messages on the server the string "0E0" will be returned. This is will give a true value in a boolean context, but zero in a numeric context. If there was an error authenticating the user then undef will be returned. apop ( [ USER [, PASS ]] ) Authenticate with the server identifying as "USER" with password "PASS". Similar to "login", but the password is not sent in clear text. To use this method you must have the Digest::MD5 or the MD5 module installed, otherwise this method will return undef. banner () Return the sever's connection banner capa () Return a reference to a hash of the capabilities of the server. APOP is added as a pseudo capability. Note that I've been unable to find a list of the standard capability values, and some appear to be multi-word and some are not. We make an attempt at intelligently parsing them, but it may not be correct. capabilities () Just like capa, but only uses a cache from the last time we asked the server, so as to avoid asking more than once. top ( MSGNUM [, NUMLINES ] ) Get the header and the first "NUMLINES" of the body for the message "MSGNUM". Returns a reference to an array which contains the lines of text read from the server. list ( [ MSGNUM ] ) If called with an argument the "list" returns the size of the message in octets. If called without arguments a reference to a hash is returned. The keys will be the "MSGNUM"'s of all undeleted messages and the values will be their size in octets. get ( MSGNUM [, FH ] ) Get the message "MSGNUM" from the remote mailbox. If "FH" is not given then get returns a reference to an array which contains the lines of text read from the server. If "FH" is given then the lines returned from the server are printed to the filehandle "FH". getfh ( MSGNUM ) As per get(), but returns a tied filehandle. Reading from this filehandle returns the requested message. The filehandle will return EOF at the end of the message and should not be reused. last () Returns the highest "MSGNUM" of all the messages accessed. popstat () Returns a list of two elements. These are the number of undeleted elements and the size of the mbox in octets. ping ( USER ) Returns a list of two elements. These are the number of new messages and the total number of messages for "USER". uidl ( [ MSGNUM ] ) Returns a unique identifier for "MSGNUM" if given. If "MSGNUM" is not given "uidl" returns a reference to a hash where the keys are the message numbers and the values are the unique identifiers. delete ( MSGNUM ) Mark message "MSGNUM" to be deleted from the remote mailbox. All messages that are marked to be deleted will be removed from the remote mailbox when the server connection closed. reset () Reset the status of the remote POP3 server. This includes resetting the status of all messages to not be deleted. quit () Quit and close the connection to the remote POP3 server. Any messages marked as deleted will be deleted from the remote mailbox. NOTES
If a "Net::POP3" object goes out of scope before "quit" method is called then the "reset" method will called before the connection is closed. This means that any messages marked to be deleted will not be. SEE ALSO
Net::Netrc, Net::Cmd AUTHOR
Graham Barr <gbarr@pobox.com> COPYRIGHT
Copyright (c) 1995-2003 Graham Barr. 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.18.2 2014-01-06 Net::POP3(3pm)
All times are GMT -4. The time now is 09:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy