sh interactive?

2005-03-26 Thread Alejandro Pulver
Hello,

How can I use 'sh' as an interactive shell?

My configuration files are the defaults.

The file '.profile' has the following:

[...]
# set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.shrc; export ENV
[...]

The file '.shrc' has the following:

[...]
# Enable the builtin emacs(1) command line editor in sh(1),
# e.g. C-a -> beginning-of-line.
set -o emacs
[...]

However it does not read '.shrc' even if I call it with '-i'.

Will this work if I use 'sh' as my default shell (I use 'tcsh')?

Thanks and Best Regards,
Ale
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: .sh interactive ok, from crontab, not

2002-11-25 Thread Matthew Seaman
On Mon, Nov 25, 2002 at 07:47:46AM +0100, Len Conrad wrote:

> >Try running 'ps' using the -w flag (wide column mode):
> >
> >  if ( ps -auxw | grep -iq "^root.*master" ) ; then
> >
> >I've tested this and it works.
> 
> here, too, thanks!!

One -w switches from 80 column width to 132 column width, but two -w's
gives you unlimited width ps output.

Cheers,

Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.   26 The Paddocks
  Savill Way
  Marlow
Tel: +44 1628 476614  Bucks., SL7 1TH UK

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: .sh interactive ok, from crontab, not

2002-11-24 Thread Len Conrad


Okay, I was able to duplicate your problem. It is due to the output of 'ps'
being truncated to 80 columns, the default terminal size. You are likely
running a wide terminal display on your interactive session (as I do)


yep, TeraTerm on Windows, very wide display.


but cron will see the default 80 column terminal. This is the difference 
between the two.

ugh, amazing!


Try running 'ps' using the -w flag (wide column mode):

  if ( ps -auxw | grep -iq "^root.*master" ) ; then

I've tested this and it works.


here, too, thanks!!

Len


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: .sh interactive ok, from crontab, not

2002-11-24 Thread Paul A. Scott

Oh, besides (or instead of) using the -w flag, you might also consider just
shorting the width of the output lines. Since you don't need all the
information between the user and command fields, you could just use:

if ( ps -ax -o user,command | grep -iq "^root.*master" ) ; then

Another possibility arises when a daemon writes its own process id into
/var/run/ when it starts up, and removes it on termination. So, you could
possibly test for the existence of the .pid file, such as:

if [ -f /var/run/master.pid ] ; then

Hope this helps.

Paul

-- 
Paul A. Scott
mailto:[EMAIL PROTECTED]
http://skycoast.us/pscott/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: .sh interactive ok, from crontab, not

2002-11-24 Thread Paul A. Scott

Okay, I was able to duplicate your problem. It is due to the output of 'ps'
being truncated to 80 columns, the default terminal size. You are likely
running a wide terminal display on your interactive session (as I do) but
cron will see the default 80 column terminal. This is the difference between
the two.

Try running 'ps' using the -w flag (wide column mode):

  if ( ps -auxw | grep -iq "^root.*master" ) ; then

I've tested this and it works.

Paul

-- 
Paul A. Scott
mailto:[EMAIL PROTECTED]
http://skycoast.us/pscott/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: .sh interactive ok, from crontab, not

2002-11-24 Thread Len Conrad


What does your crontab entry look like?


*/10*   *   *   *   root/usr/local/bin/watchdog.sh



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: .sh interactive ok, from crontab, not

2002-11-24 Thread Paul A. Scott
> I forgot to mention, "I'm blue in the face"

Sorry, didn't know what you'd already done. Thought I had to ask.

> ... but your version, or my multiple versions, have never mishaved from the
> command line, it's running from crontab that does comes out inverted.

What does your crontab entry look like?

Paul

-- 
Paul A. Scott
mailto:[EMAIL PROTECTED]
http://skycoast.us/pscott/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: .sh interactive ok, from crontab, not

2002-11-24 Thread Len Conrad


Well, it was just a guess. :) I tested against my 'named' daemon, using the
code you supplied and it works fine.


same code works fine for my AV daemon, but not for the MTA daemon


 What version of FreeBSD?


4.5


Are you using
the 'stock' shell?


yes


 Did you look at the output from grep to see what you get?


I forgot to mention, "I'm blue in the face"


How about splitting the test onto more than one line so that you can echo
and then test the status code.


done that  :))


ps -aux | grep -i "^root.*master"
STATUS=$?
echo "got $STATUS"
if [ $STATUS = 0 ] ; then


here's what I get from the command line:

ps -aux | grep -i "^root.*master"
STATUS=$?
echo "got $STATUS"
if [ $STATUS = 0 ] ; then

#if ( ps aux | grep -qi "^root.*master" )
#then
#echo "then: exit code equal 0"
exit 0
else

gives:

# /usr/local/bin/watchdog.sh
root  48701  0.0  0.9  1012  572  ??  Is5:01PM   0:02.30 
/usr/libexec/postfix/master
got 0

... but your version, or my multiple versions, have never mishaved from the 
command line, it's running from crontab that does comes out inverted.

I´ll see what happens in 10 min with next crontab run

thanks

Len


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message


Re: .sh interactive ok, from crontab, not

2002-11-24 Thread Paul A. Scott

>> From: Len Conrad <[EMAIL PROTECTED]>
>> It works for me, and I suspect that it's working for you, too.
> 
> well, it's really not.  The crontab execution is trying to run the daemon
> even when the daemon shows up in "ps aux".

Well, it was just a guess. :) I tested against my 'named' daemon, using the
code you supplied and it works fine. What version of FreeBSD? Are you using
the 'stock' shell? Did you look at the output from grep to see what you get?
How about splitting the test onto more than one line so that you can echo
and then test the status code.

ps -aux | grep -i "^root.*master"
STATUS=$?
echo "got $STATUS"
if [ $STATUS = 0 ] ; then

That might tell you something if you get a status 2.

If you'd like, send me your exact script, and crontab entry; I'll test it
here.

Paul

-- 
Paul A. Scott
mailto:[EMAIL PROTECTED]
http://skycoast.us/pscott/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: .sh interactive ok, from crontab, not

2002-11-24 Thread Len Conrad


> if ( ps aux | grep -i "^root.*master" ) > /dev/null
> then
> echo "then: exit code equal 0"
> exit 0
> else
> 
>
> ... when run from the command line, the echo text displays. But, when run
> from crontab every 10 minutes, the if fails, and the else clause runs.
>
> I've tried every syntax I know, but still can't get this logic to work.

It works for me, and I suspect that it's working for you, too.


well, it's really not.  The crontab execution is trying to run the daemon 
even when the daemon shows up in "ps aux".

 However, you
may not see the results expected if you are piping the cron output through
sendmail


I'm not, and anyway the echo is after the IF condition "fails".


Also, make sure that you're running the expected shell. Check the SHELL=
line in crontab, or force the script to run via the expected shell by
running 'sh script' instead of just 'script', or tell the script what shell
to run by adding something like the following on the first line:

#!/bin/sh


already there, and /etc/crontab also contains

SHELL=/bin/sh


Although this isn't related to your problem , you might find it simpler to
use the -q option on grep instead of redirecting the output. For example,

if ( ps -aux | grep -q -i "^root.*master" ); then

instead of,


ok.

thanks
Len


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: .sh interactive ok, from crontab, not

2002-11-24 Thread Paul A. Scott
> From: Len Conrad <[EMAIL PROTECTED]>
  
> This snippet works fine...
> 
> if ( ps aux | grep -i "^root.*master" ) > /dev/null
> then
> echo "then: exit code equal 0"
> exit 0
> else
> 
> 
> ... when run from the command line, the echo text displays. But, when run
> from crontab every 10 minutes, the if fails, and the else clause runs.
> 
> I've tried every syntax I know, but still can't get this logic to work.

It works for me, and I suspect that it's working for you, too. However, you
may not see the results expected if you are piping the cron output through
sendmail, because the 'echo "then: ...' could be interpreted as a mail
header. Make certain that you output a blank line, eg., echo "", *before*
any lines that contain 'some-word:' so that sendmail stops looking for
headers.

Just a guess.

Also, make sure that you're running the expected shell. Check the SHELL=
line in crontab, or force the script to run via the expected shell by
running 'sh script' instead of just 'script', or tell the script what shell
to run by adding something like the following on the first line:

#!/bin/sh

Although this isn't related to your problem , you might find it simpler to
use the -q option on grep instead of redirecting the output. For example,

if ( ps -aux | grep -q -i "^root.*master" ); then

instead of,

if ( ps aux | grep -i "^root.*master" ) > /dev/null; then

Paul

-- 
Paul A. Scott
mailto:[EMAIL PROTECTED]
http://skycoast.us/pscott/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



.sh interactive ok, from crontab, not

2002-11-24 Thread Len Conrad
Trying to write a little watch-dog/keep-alive script for a couple of 
related daemons, an MTA and an SMTP AV scanner.

This snippet works fine...

if ( ps aux | grep -i "^root.*master" ) > /dev/null
then
echo "then: exit code equal 0"
exit 0
else


... when run from the command line, the echo text displays. But, when run 
from crontab every 10 minutes, the if fails, and the else clause runs.

I've tried every syntax I know, but still can't get this logic to work.

Upstream in the same script, there is another "if" with same syntax that 
also checks a related daemon, and that IF works as expected, both 
interactively and from crontab.

suggestions?

Len


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message