How to get a variables from two different txt files and need to run a command using that values?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get a variables from two different txt files and need to run a command using that values?
# 8  
Old 05-20-2016
This is why you're supposed to use the return code instead of making the computer swallow the human-readable error messages. There's lots of ways the printing could work, but only one way a return code works.

In this case, it must be printing these messages to standard error. That's the place things the computer isn't supposed to be handling like this go. We can force the script to intercept these things it's not supposed to handle with a redirection.

Code:
while read NODE PORT UID PWD
do
        cfsend n:"${NODE}" port:${PORT} uid:${UID}  pwd:${PWD} pn:CHCKDIR ud:5563 trtype:c rcmd:"pwd" 2>&1 | grep -iq "failed communicating with partner" && echo "PS is down on $NODE"
done < table > output.log 2>/dev/null

# 9  
Old 05-25-2016
Hi Corona,

I passed the cfsend command line output into one log file,from there i did grep command and written a logging to find only
"Failed Communicating with partner" and corresponding node name

its working fine for couple of node names,will try add more nodes in the txt file

And i have one question wanna confirm with you :when passing values from the txt file-how do i separate the values(node,port,uid and pwd)

i am thinking using a space between the values.
Exmp....

node port uid pwd
node port uid pwd
node port uid pwd

is that correct or any other way?
# 10  
Old 05-25-2016
Code:
# for space-separated file
while read NODE PORT UID PWD
do
...
done < datafile

# for comma separated file
while IFS="," read NODE PORT UID PWD
do
...
done < datafile

#etc

# 11  
Old 05-25-2016
thanks Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read in txt file and run a different command for each line

hi, i'm trying to write a tcsh script that reads in a text file (one column) and the runs a different command for each line of text. i've found lots of example commands for bash, but not for tcsh. can anyone give me a hint? thanks, jill (8 Replies)
Discussion started by: giuinha
8 Replies

2. UNIX for Dummies Questions & Answers

Read in Multiple log files and output selected variables and values to cvs file

I have several problems with my problems: I hope you can help me. 1) the If else statement I am getting an error message. My syntax must be incorrect because the entire statement is throwing an error. For example in filew.log if these items don't exist Memsize, SASFoundation and also if... (0 Replies)
Discussion started by: dellanicholson
0 Replies

3. Shell Programming and Scripting

Find and compare values from different txt files

Hello, i am new in Bash. Actually i have a directory : /home/resultfiles and inside i have these txt files: 531_1.out.res, 531_2.out.res , 531_3.out.res 532_1.out.res, 532_2.out.res , 532_3.out.res 533_1.out.res, 533_2.out.res, 533_3.out.res All these txt files has this format : num_q all... (3 Replies)
Discussion started by: nimpoura
3 Replies

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

5. Shell Programming and Scripting

Shell script to run command + compare values and post a warning message.

Hi all, I am trying to create shell script to run command then compare values with rule set for every 5 seconds and post a warning message if the compared value meet the rules. -the script is related to Oracle/Sun product messaging server 6.2 1) command that need to be run to gather... (2 Replies)
Discussion started by: Mr_47
2 Replies

6. UNIX for Dummies Questions & Answers

rusty with cp command -- how to cp all .doc files with .txt extension

I'm rusty with cp, so I was wondering: is it possible to cp all the .doc files in a folder and make them .txt files? Can you use cp to do that? (3 Replies)
Discussion started by: Straitsfan
3 Replies

7. Shell Programming and Scripting

Script to run a command on all txt files present in a dir structure

Hi, I have a directory structure like the one given below root\a\b1 root\a\b2 root\b\b1 root\b\b2 . . . root\j\b1 root\j\b2 Now, there are a txt files in each dir and subdir, there is a root.txt I have to write a script where in i have to run a command called "genrb <filename>"... (6 Replies)
Discussion started by: vikramsinghnegi
6 Replies

8. UNIX for Dummies Questions & Answers

trouble using read to store values in variables from command output

I know there are caveats about using read in pipelines because read is treated by a subshell. I know this but I can't think of any way to accomplish this regardless, I'm still a rookie. I hope somebody will be able to interpret what it is that I'm trying to accomplish and correct me. ... (2 Replies)
Discussion started by: ProGrammar
2 Replies

9. Shell Programming and Scripting

command to list .txt and .TXT file

Hi expersts, in my directory i have *.txt and *.TXT and *.TXT.log, *.txt.log I want list only .txt and .TXT files in one command... how to ?? //purple (1 Reply)
Discussion started by: thepurple
1 Replies

10. Solaris

list files .txt and .TXT in one command

Dear experts, In a directory i have both *.TXT and *.txt files. I have a script- for file in `ls *.txt`; do mv $file /tmp/$file How to list both *.txt and*.TXT file in one command so that script will move both .txt or .TXT whatever it find. br//purple (4 Replies)
Discussion started by: thepurple
4 Replies
Login or Register to Ask a Question