To take two variables from a file and act as an input for the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To take two variables from a file and act as an input for the script
# 1  
Old 12-10-2012
To take two variables from a file and act as an input for the script

Hi,

I have done the scripting such that it will read input line by line from a txt file and is passed through a script, but now my requirement is to pass two variables into a script from a file, how could I do this or is there any other better idea ?

for reading singe input from a file, line by line I have used the below script
Code:
while read -r inputname
do
  java weblogic.Admin -adminurl  -username weblogic -password xxxxx  -mbean Name=$inputname,ServerRuntime=aaaa,Type=JDBCConnectionPoolRuntime" > output.log
done < filename.txt

Now the requirement is since there needs to be another server also which needs to be monitored, I need to pass as a dynamic value for ServerRuntime

any input is much appreciated!!thanks in advance

Last edited by Franklin52; 12-10-2012 at 03:59 PM.. Reason: Please use code tags
# 2  
Old 12-10-2012
What does the content of filename.txt look like? Where do you expect to get this dynamic value, from the file?
# 3  
Old 12-10-2012
Hi Corona

The content of the filename.txt is customizable

I am planning to use two columns, if there is any other better way , i am happy to use it


Code:
Name      ServerRuntime
abc       aaaaa
xyz        bbbbb

Right, i am planning to get this dynamic value also for "ServerRuntime" from file along with "Name"

Last edited by Scrutinizer; 12-10-2012 at 04:26 PM.. Reason: typo; mod: code tags
# 4  
Old 12-10-2012
Easily done then.
Code:
while read -r var1 var2
do
....
done < inputfile

This User Gave Thanks to Corona688 For This Post:
# 5  
Old 12-11-2012
great, will check and update you
Thanks much again for your quick response

---------- Post updated 12-11-12 at 09:09 AM ---------- Previous update was 12-10-12 at 03:45 PM ----------

cool, worked as a charm and thanks again to you Corona!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Enhance existing script: Extract Multiple variables & Input in an echo string

Hi Experts I need your help to optimize my script to execute better as I have nearly 1M records & the script is taking close to 40 minutes to execute, so would need support on a faster alternative. Input: file {"house":"1024","zip":"2345","city":"asd","country":"zzv"}... (2 Replies)
Discussion started by: nk1984
2 Replies

2. Shell Programming and Scripting

For in loop - two input variables

When I create a newfile, I am using the filename as a variable to create the new filename. When I ouput it, the filename contains the file extension in the middle of the file example: router1.txtshcdpneighbors.txt router2.logshcdpneighbors.txt My initial approach was to strip it out, now I... (2 Replies)
Discussion started by: dis0wned
2 Replies

3. Shell Programming and Scripting

HELP - loop a curl command with different variables from input file

Hi guys! Kind of new to bash scripting and now I'm stuck. I need to curl with these variables: "{ \"nodename\": \"$1\", \"ipaddress\": \"$2\", \"poolname\": \"$3\", \"port\": \"$4\", \"loadbalancer\" : \"$5\" }" and my input_file.txt contains server001 10.10.10.01 serverpool1 80... (4 Replies)
Discussion started by: yort
4 Replies

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

5. Shell Programming and Scripting

Passing variables to an input file

Hi All, I have to insert 2 values to a text file in specific places. I have been able to extract each variable value via a script but am not able to send these variable values to the text file. Pasted is the script for extracting the variable values: for i in `ls -1` ... (2 Replies)
Discussion started by: danish0909
2 Replies

6. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

7. Shell Programming and Scripting

awk script need to act on same file on matced case

Hello, I have a log file , i want to delete the lines of the log file which is match with 1st and 5th field with different patterns. Once it will meet with that condition it will delete that line from the log . I dont want to create any temp file over there. Successfully able to retrieve the... (1 Reply)
Discussion started by: posix
1 Replies

8. Shell Programming and Scripting

For loop using input file doesn't expand variables

Hi, I'm using a for loop reading from an input file that contains files, whose path includes a variable name. But the for loop doesn't expand the variable and therefore can't find the file. Here's an example: File BACKUPFILES /home/John/alpha /home/Sue/beta... (8 Replies)
Discussion started by: Hesiod
8 Replies

9. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

10. Shell Programming and Scripting

Script that takes in variables, and outputs to another text or script file

Ok, I sort of need to create a command files that will be ftped to another server to run. I have some input variable that will need to be read, and then transformed into another script file. Here are some examples. Server 1: outputCmd.sh passing in ./outputCmd.sh nh8oaxt Release_4_0... (1 Reply)
Discussion started by: orozcom
1 Replies
Login or Register to Ask a Question