pbrown@vtopus.cs.vt.edu (Patrick R. Brown) (04/10/91)
I am trying to set up a shell script to check for mail on a remote machine. The script is the following: #! /bin/sh # # Check mail on CSGrad since I can't get mail here!!!! # if [ `rsh csgrad mail -e` ] then echo You have mail on CSGrad. else echo You do not have mail on CSGrad. fi This looks nice, but it doesn't work. (I never "have" mail, even when I do) What can I do (if anything) to get 'rsh' to return the status of the command being run remotely. The Ultrix man pages don't have anything to say on this topic. If 'rsh' won't do this, are there any other ideas? Thanks in advance, Pat -- Patrick R. Brown __ _________ email: pbrown@csgrad.cs.vt.edu \ \ / ___ __/ Virginia Tech: smail: 375 New Kent Rd. \ \/ / / / "Po but Proud" Blacksburg, VA 24060 \__/ /_/ (703) 552-4016
tchrist@convex.COM (Tom Christiansen) (04/10/91)
From the keyboard of pbrown@vtopus.cs.vt.edu (Patrick R. Brown): :I am trying to set up a shell script to check for mail on a remote :machine. The script is the following: : : #! /bin/sh : # : # Check mail on CSGrad since I can't get mail here!!!! : # : if [ `rsh csgrad mail -e` ] : then : echo You have mail on CSGrad. : else : echo You do not have mail on CSGrad. : fi : :This looks nice, but it doesn't work. (I never "have" mail, even when :I do) What can I do (if anything) to get 'rsh' to return the status of :the command being run remotely. The Ultrix man pages don't have :anything to say on this topic. If 'rsh' won't do this, are there any :other ideas? You can use Maarten Litmath's ersh script where you have rsh. Your script will behave as you expect it to. --tom #!/bin/sh # @(#)ersh 2.4 91/01/30 Maarten Litmaath # This rsh front-end returns the exit status of the remote command. # It works OK with sh/csh-compatible shells on the remote (!) side. # If there is no remote command present, /usr/ucb/rlogin is invoked. # Usage: see rsh(1). unset hostname lflag nflag user case $1 in -l) ;; *) hostname=$1 shift esac case $1 in -l) lflag=-l user=$2 shift 2 esac case $1 in -n) nflag=-n shift esac case $hostname in '') hostname=$1 shift esac case $# in 0) exec /usr/ucb/rlogin $lflag ${user+"$user"} "$hostname" esac AWK=' NR > 1 { print prev; prev = $0; prev1 = $1; prev2 = $2; } NR == 1 { prev = $0; prev1 = $1; prev2 = $2; } END { if (prev1 ~ /[0-9]*[0-9]0/) exit(prev1 / 10); if (prev1 == "0") exit(prev2); print prev; exit(1); } ' exec 3>&1 /usr/ucb/rsh "$hostname" $lflag ${user+"$user"} $nflag \ "(${*-:}); sh -c '"'echo "$0 $1" >&2'\'' $?0 "$status"' \ 2>&1 >&3 3>&- | awk "$AWK" >&2 3>&-
cpcahil@virtech.uucp (Conor P. Cahill) (04/10/91)
pbrown@vtopus.cs.vt.edu (Patrick R. Brown) writes: >I am trying to set up a shell script to check for mail on a remote >machine. The script is the following: > # > if [ `rsh csgrad mail -e` ] >This looks nice, but it doesn't work. (I never "have" mail, even when rsh does not return the status of the command that it executed on the other machine. There is nothing you can do to change that, however you have two other options. 1. Use the following: rsh csgrad "if mail -e; then echo you have mail; else \ echo no mail; fi" 2. have csgrad forward the mail to your current machine so that yout don't have to worry about checking the mail somewhere else -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc. uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170
sweh@tharr.UUCP (Stephen Harris) (04/11/91)
In article <PBROWN.91Apr9194949@vtopus.cs.vt.edu} pbrown@vtopus.cs.vt.edu (Patrick R. Brown) writes: }I am trying to set up a shell script to check for mail on a remote }machine. The script is the following: } } #! /bin/sh } # } # Check mail on CSGrad since I can't get mail here!!!! } # } if [ `rsh csgrad mail -e` ] } then } echo You have mail on CSGrad. } else } echo You do not have mail on CSGrad. } fi } }This looks nice, but it doesn't work. (I never "have" mail, even when I 'spose you could try something line #!/bin/sh # rsh csgrad "mail -e && echo You have mail on CSGrad || echo You do not have mail on CSGrad" NOTE: this hasn't been tried by me (inappropriate machine setup :-) ) but it should work - just get all the processing and output done on CSGrad. Hope this helps -- Stephen Harris Disclaimer: me have an opinion? | Email: ..!ukc!axion!tharr!sweh What an idea! | sweh%tharr.uucp@uk.co.bt.axion Wanted: humour transplant | tharr!sweh@uk.ac.ukc <-- tharr *free* public access to Usenet in the UK 0234 720202 -->
py@meadow.uucp (Peter Yeung) (04/13/91)
In article <1991Apr10.142613.12656@virtech.uucp> cpcahil@virtech.uucp (Conor P. Cahill) writes: > 2. have csgrad forward the mail to your current machine so that > yout don't have to worry about checking the mail somewhere else > Can you please tell me how? Or which FM to read? I would like to know. >-- >Conor P. Cahill (703)430-9247 Virtual Technologies, Inc. >uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 > Sterling, VA 22170 -- Peter Yeung Amdahl Canada Ltd., Software Development Center 2000 Argentia Road, Plaza 2, Suite 300 Mississauga, Ont. L5N 1V8 Phone: (416) 542-6300 Fax: (416) 858-2233
cpcahil@virtech.uucp (Conor P. Cahill) (04/13/91)
py@meadow.uucp (Peter Yeung) writes: >In article <1991Apr10.142613.12656@virtech.uucp> cpcahil@virtech.uucp (Conor P. Cahill) writes: >> 2. have csgrad forward the mail to your current machine so that >> yout don't have to worry about checking the mail somewhere else >> >Can you please tell me how? Or which FM to read? I would like to know. There are two ways that you can use (depending upon your mail handler). 1. mail -Fsystem!user (or user@system) this is documented on the mail(1) man page 2. place system!user (or user@system) in a .forward file in your login directory. This is documented in the sendmail and smail manual pages. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc. uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170