How to redirect the output when we are usinf EOF in the same line?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to redirect the output when we are usinf EOF in the same line?
# 1  
Old 09-14-2015
Wrench How to redirect the output when we are usinf EOF in the same line?

need to login 4 systems to check whether the systems are accessible or not using rlogin command,after each login i will exit.After issuing the command rlogin abc if it is not responding i will get a message of "connection timed out" . So i want to automate this task .so i tried like below :
EX:
Code:
rlogin abc <<EOF
 6
 EOF
 rlogin xyz <<EOF 
    n     
6
 EOF
 rlogin  pqr <<EOF     
6     
EOF     
rlogin klv <<EOF 
    n
 6 
    EOF

But how can i check if the system responds or not.

When i do
Code:
 rlogin abc

and the system throws an error
Code:
"Connection Timed out "

then i want it as notification through mail. else it should continue with the process.

Any help greatly helps me Smilie

Last edited by charanarjun; 09-14-2015 at 04:20 PM.. Reason: adding code tags
# 2  
Old 09-14-2015
You can put other commands after the beginning of a here document <<string as long as they're on the same line. You can extend "same line" with backslashes at the end of the line.

Code:
command 2>&1 <<EOF | another command | another command
text
that
gets
fed
into
first
command
EOF

I don't understand your code, I suspect it got stripped of newlines or otherwise garbled. Please post code in code tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How To Redirect The Output When We Are Usinf EOF In The Same Line?

need to login 4 systems to check whether the systems are accessible or not using rlogin command,after each login i will exit.After issuing the command rlogin abc if it is not responding i will get a message of "connection timed out" . So i want to automate this task .so i tried like below: EX: ... (3 Replies)
Discussion started by: kankuro9x
3 Replies

2. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

3. Shell Programming and Scripting

Redirect output of command line to for loop

I would like to redirect output of command line in for loop as $line. Output should be processed as line but instead it throw whole output. Could somebody help me on how to redirect output of command line and process it line by line without sending output to any file. below is my code ... (1 Reply)
Discussion started by: tapia
1 Replies

4. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

5. Shell Programming and Scripting

Output selection with EOF

I have a script: #!/bin/ksh runmqsc CERN.PROD <<EOF dis chs(to.*) end EOF which gives me the output as: 1 : dis chs(to.*) AMQ8417: Display Channel Status details. CHANNEL(TO.CGPRODAPP2) CHLTYPE(CLUSRCVR) CONNAME(10.60.16.50) CURRENT ... (5 Replies)
Discussion started by: Daniel Gate
5 Replies

6. Shell Programming and Scripting

Redirect output directly with DOS end of line

Hi guys, I have some echo scripts and awk scripts like these: echo "some text" > output1 . . awk '{....}{print}' input > output2Both output1 and output2 are saved with unix END Of Line, then, is there an option to include within echo command and awk command to save the output as DOS END Of... (3 Replies)
Discussion started by: Ophiuchus
3 Replies

7. Shell Programming and Scripting

sed truncating last line if EOF is not with newline

sed 's|^xyz.abc *= *.*|xyz.abc=60|' /test/myFile.properties > /test/myFile.properties1 myFile.properties has the last line as xyz.abc=23 does not end with newline. When I run this command the last line is truncated if there is no newline character at EOF. Looking for an alternative here. (1 Reply)
Discussion started by: sunn_hps
1 Replies

8. Shell Programming and Scripting

cat redirect EOF missing text

Hello attempting to redirect out to create a startup script in solaris. The steps are working but the $1 entry is being left out. syntax below and content of output file below. cat > S99build << EOF > #!/bin/bash > case $1 in > 'start') > /usr/os-buildsol.sh > > ;; > esac > exit 0 >... (3 Replies)
Discussion started by: juanb25
3 Replies

9. Shell Programming and Scripting

line 85: unexpected EOF while looking for matching `"'

hello everyone...im having this problem with unexpected EOF with line 85 which is..i cant see whats wrong with it..can any1 plz help me out. read -p "$p1 please enter the number of tries you wish to have:" lifeline function main() { guessnum=0 read -p "Please... (6 Replies)
Discussion started by: Freakhan
6 Replies
Login or Register to Ask a Question