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 12-04-2017
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:
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:
Code:
rlogin abc

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

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

Any help greatly helps me Linux

Moderator's Comments:
Mod Comment Please use CODE tags correctly as required by forum rules!

Last edited by RudiC; 12-04-2017 at 06:38 AM.. Reason: Added CODE tags.
# 2  
Old 12-04-2017
Welcome to the forum.

Please be aware that rlogin is NOT today's tool of choice to connect to network nodes; you may want to consider secure tools, e.g. ssh, instead (if rlogin hasn't been aliased to ssh on your system anyhow, that is).

For error conditions as described you may want to check the command's exit code, either with an if construct:
Code:
if rlogin abc; then ... ; fi

or by evaluating the shell variable $?
Code:
ERRC=$?

IMMEDIATELY after the command was run.

EDIT: With your "here documents" (the data between EOF and EOF), the remote system will try to execute the lines as commands, and if 6 and n are not installed / aliased, you'll have error exit codes as well, although the nodes are readily available on the net.

Last edited by RudiC; 12-04-2017 at 06:53 AM..
# 3  
Old 12-04-2017
Quote:
Originally Posted by RudiC
EDIT: With your "here documents" (the data between EOF and EOF), the remote system will try to execute the lines as commands
For a HERE document written in the OP's way, wouldn't the EOF have to be in the leftmost column?
This User Gave Thanks to rovf For This Post:
# 4  
Old 12-04-2017
Yes, of course, I forgot to mention that. It only showed up when I introduced the 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:... (1 Reply)
Discussion started by: charanarjun
1 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