Sponsored Content
Top Forums Shell Programming and Scripting How to get variable input from a file Post 87918 by maheshsri on Saturday 29th of October 2005 06:44:26 AM
Old 10-29-2005
Bug How to get variable input from a file

Hi guys,

I want to input some variables from a file.
I tried it with following script,

for i in 1 2 3 4
do
read varible1 varible2 < ddd.txt

echo $varible1 $varible2

done


ddd.txt file content as follows,


1 100
2 200
3 300
4 400

But problem is, it only take the two variables form the first line. I want to take all the variable and to print it .


Can some body tell me how can I change my scrip to take all varables.


Regards,
Mahesh Fernando.
 

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Input a variable and write to a file using awk

Hi I am trying to edit a csv file. Bacically I need to input a search variable and the value that must be changed in one of the fields corresponding to that searched variable. My csv file looks like so: 1,1A,5 1,1B,2 1,1C,3 2,2A,7 2,2B,4 2,2C,0 3,3A,1 3,3B,6 3,3C,4 I want to... (4 Replies)
Discussion started by: ladyAnne
4 Replies

2. Shell Programming and Scripting

KSH: Compare variable to $1 in an input file

Hello, I am working with KSH on AIX and I have 2 files generated from different sources... as seen below: FILE1 FILE2 AAA AAA@ABS0001C BBB BBB@ABS0003D CCC CCC@ABS0023A DDD DDD@ABC0145D EEE EEE@ABS0090A FFF FFF@ABS0002A GGG GGG@ABC0150D HHH FILE1 is main main data source,... (4 Replies)
Discussion started by: right_coaster
4 Replies

3. Shell Programming and Scripting

Reading from a File and Using as an Input variable

I need to know how the the string constant from Input File should be read and provide as input data for the script . INPUT FILE CONST VARIABLE myname=/root/dir/syslog/myname1 myname=/root/dir/syslog/myname2 myname=/root/dir/syslog/myname3 urname=/root/dir/syslog/urname1... (6 Replies)
Discussion started by: baraghun
6 Replies

4. Shell Programming and Scripting

awk built-in variable for input file

Hi guys, Does awk have a built-in variable which I can use to display the input file it's currently reading? I'm currently concatenating multiple files using awk and later on do some parsing. But for now, I want to add an extra column in the main output data file - basically putting in the... (3 Replies)
Discussion started by: Det7
3 Replies

5. UNIX for Dummies Questions & Answers

SQL Script to use variable value from input file

Here is the requirement, When I run the "run file KSH (sql)", it should substitute '${pCW_Bgn_DT}' with 201120 and '${pCW_End_DT}' with 201124 Input File ---------- $ cat prevwk.dat 201124 20110711 run file KSH (sql) ------------------ In this file, I want to use the variables... (1 Reply)
Discussion started by: shanrice
1 Replies

6. Shell Programming and Scripting

Passing variable as an input file to AWK comand

Hi, I would like to compare 2 files using awk, which I can do by using: awk 'NR==FNR{a;next} (NR > 32 && $2 in a) {print $0}' File1 and File2. If the name of the File1 is in another file (for example, column 4 in File 3) then how can I pass this column 4 to the awk command. Thanks in... (1 Reply)
Discussion started by: ezhil01
1 Replies

7. Shell Programming and Scripting

Detail on For loop for multiple file input and bash variable usage

Dear mentors, I just need little explanation regarding for loop to give input to awk script for file in `ls *.txt |sort -t"_" -k2n,2`; do awk script $file done which sorts file in order, and will input one after another file in order to awk script suppose if I have to input 2 or... (4 Replies)
Discussion started by: Akshay Hegde
4 Replies

8. Shell Programming and Scripting

XML variable for input in same input file

Dear All , i stuck in one problem executing xml .. i have input xml as <COMMAND name="ARRANGEMENT.WRITE" timestamp="0" so="initial"> <SVLOBJECT> <LONG name="CSP_PMNT_ID" val="-1"/> <MONEY name="CSP_CEILING" amount="0.0" currency="AUD"/> ... (6 Replies)
Discussion started by: arvindng
6 Replies

9. Shell Programming and Scripting

Checking the file depending on the input variable

Hi I have a requirement of taking time as input variable outside the script.depending on the time it will check the file output .like ./script.sh <30 min> so script.sh should run every 5 minutes ie.6 times to check the output file.Can any one please help here. (7 Replies)
Discussion started by: netdbaind
7 Replies

10. Shell Programming and Scripting

Can't input large file to variable

I have a file that I'm trying to place into a variable. I've tried the following: DATE=`date +%Y%m%d` filez=$(cat /tmp/Test_$DATE.txt)DATE=`date +%Y%m%d` filez=$(</tmp/Test_$DATE.txt)DATE=`date +%Y%m%d` filez=$(`cat /tmp/Test_$DATE.txt`)None of these lines allows the file to go into the... (3 Replies)
Discussion started by: newbie2010
3 Replies
CGIPARSE(8)						     DACS Web Services Manual						       CGIPARSE(8)

NAME
cgiparse - CGI argument parsing utility SYNOPSIS
cgiparse [mode] [-enc {none | url | mime | dacs}] [-in filename] [-d] [-nonewline] [-qs query-string] [-copy filename] [[-n name filename]...] DESCRIPTION
This program is part of the DACS suite. It is a stand-alone program that neither accepts the usual DACS command line options (dacsoptions) nor accesses any DACS configuration files. This utility is used by web-based scripts (shell scripts in particular) to obtain their CGI arguments, which can be obtained from a URI's query component or in an encoded entity-body read from the standard input (as with the POST method). The form content types[1] application/x-www-form-urlencoded and multipart/form-data are both understood. The program has several different modes of operation, one of which may be specified by the first command line argument. cgiparse combines query arguments found in the QUERY_STRING environment variable with arguments found in the message body it reads from the standard input. If an argument name is duplicated the result is indeterminate. OPTIONS
The mode may be one of the following: -arg variable-name Emit the value of the CGI argument variable-name, then exit. If there is no such argument, the exit status will be 1 instead of 0. -targ variable-name Test if the CGI argument variable-name exists. If there is no such argument, the exit status will be 1, otherwise it will be 0. -html Emit an HTML document that lists the CGI argument names and their values. -one Emit a listing of the CGI argument values (without the names). -sh Emit CGI arguments as a single line in the format: variable-name='variable-value'; [...] It is an error if any variable-name or variable-value is syntactically unsuitable for this format. The returned string can be used as the argument to eval to set the CGI arguments as shell variables. -text Like -html except emit text. This is the default. With this mode, the program's stdout is usually written to a file. Each line of the file has the format: variable-name variable-value (a space separates the name from the corresponding value). The file is typically read by a script to obtain the arguments, or cgiparse can be run with the -in flag to retrieve an argument. Additionally, cgiparse recognizes these options: If writing the parsed CGI arguments (-text), encode the argument value using the specified method: url means URL encoding, mime means MIME base-64 encoding, and dacs means DACS base-64 encoding. For details about these encodings, please see dacs.exprs(5)[2]. The default is none, which means that no encoding is performed (use this only when you are sure this cannot cause a problem). If reading the parsed CGI arguments (-in), decode the argument values using the specified method. The default is none, which means that no decoding is performed; if the arguments were encoded, they will be returned in that encoding, but other than this case the decoding method must match the encoding method previously used or an error is likely to occur. -qs query-string Instead of using the environment variable QUERY_STRING to get a query component, use query-string. -nonewline With -arg, do not emit a newline after printing an argument value. -d Enable debugging output. -copy filename Append the input stream to filename. This can be useful for debugging purposes. -in filename Instead of parsing CGI arguments, read variable name/value pairs (as produced by the -text flag) from filename. If filename is "-", stdin is read. -n name filename If parsing succeeds, and there is a MIME body part with a name exactly matching name, then: o if the content disposition is multipart/form-data, write the content as quoted-printable text to filename; o if the content disposition is base64, write the decoded content to filename; o otherwise the content is written verbatim to filename. If the output file exists it is truncated. EXAMPLES
The following shell script demonstrates one way of using cgiparse. #! /bin/sh tmpfile=/tmp/cgiparse.$$ cgiparse > ${tmpfile} chmod 0600 ${tmpfile} echo "Context-Type: text/plain" echo "" done= while [ "${done}x" = x ] do a= b= read a b if [ $? = 1 ] then done=1 break else echo "Arg: ${a}" echo "Is: ${b}" fi done < ${tmpfile} rm -f ${tmpfile} exit 0 The following code fragment uses cgiparse to save and then look up its CGI arguments: #! /bin/sh tmpfile=/tmp/cgiparse.$$ trap 'rm -f ${tmpfile}; exit 1' EXIT 1 2 3 13 15 cgiparse -enc mime > ${tmpfile} chmod 0600 ${tmpfile} mode=`cgiparse -in ${tmpfile} -enc mime -arg MODE` target=`cgiparse -in ${tmpfile} -enc mime -arg TARGET` The following script will print "1 2 3" to its standard output: #! /bin/sh args=`cgiparse -sh -qs "a=1&b=2&c=3"` eval "$args" echo "$a $b $c" DIAGNOSTICS
The program exits 0 if everything was fine, 1 if an error occurred. BUGS
There do not appear to be any official recommendations concerning how to handle apparently "malformed" CGI query strings that do not look like a sequence of name=value pairs. The parsing routines that cgiparse uses will flag an error if they see strings containing a component like "=foo", for example, although "foo=" is fine. SEE ALSO
RFC 3875[3], The WWW Common Gateway Interface, Version 1.2[4], HTML 4.01 Specification[5], dacs_prenv(8)[6] AUTHOR
Distributed Systems Software (www.dss.ca[7]) COPYING
Copyright2003-2012 Distributed Systems Software. See the LICENSE[8] file that accompanies the distribution for licensing information. NOTES
1. form content types http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 2. dacs.exprs(5) http://dacs.dss.ca/man/dacs.exprs.5.html#encode 3. RFC 3875 http://www.rfc-editor.org/rfc/rfc3875.txt 4. The WWW Common Gateway Interface, Version 1.2 http://ken.coar.org/cgi/cgi-120-00a.html 5. HTML 4.01 Specification http://www.w3.org/TR/html4/ 6. dacs_prenv(8) http://dacs.dss.ca/man/dacs_prenv.8.html 7. www.dss.ca http://www.dss.ca 8. LICENSE http://dacs.dss.ca/man/../misc/LICENSE DACS 1.4.27b 10/22/2012 CGIPARSE(8)
All times are GMT -4. The time now is 06:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy