<br><br><div class="gmail_quote">On Wed, Apr 16, 2008 at 8:44 AM, Patrick O'Callaghan <<a href="mailto:pocallaghan@gmail.com">pocallaghan@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
On Wed, 2008-04-16 at 10:41 -0400, Bill Davidsen wrote:<br>
> Patrick O'Callaghan wrote:<br>
> > On Tue, 2008-04-15 at 10:49 -0700, Don Russell wrote:<br>
> >> How can I tell, from a Korn shell script, if the script is running in<br>
> >> a vi sub-shell?<br>
> >><br>
> >> I have a script that has a problem when run from a vi subshell, and<br>
> >> I'd like to check for that condition and just issue an error message.<br>
> >> (I know that's not the solution to the problem, but the thing that<br>
> >> fails is being replaced, so this is a temporary "fix")<br>
> ><br>
> > Try:<br>
> ><br>
> > ls -l /proc/`cat /proc/$$/status|grep PPid|cut -f2`/exe<br>
><br>
> What on Earth are you doing here?<br>
> 1) unless you have some reason to doubt the value of $PPID, you are just<br>
>     making this look complex<br>
> 2) if this is a login shell, you will not have permission to read the<br>
>     exe symbolic link.<br>
> 3) you probably just want to see if /proc/$PPIC/cmdline matches vi<br>
<br>
</div>Duh, yes. The OP wants to know if his script is being executed from<br>
'vi'. That's one way to do it. You're right about the permissions of<br>
course, my bad, but using $PPID doesn't change that in the script.<br>
<br>
Here's a better one:<br>
<br>
ps -p $PPID -o comm=<br>
<br></blockquote></div><br>That's GREAT! It's exactly what I need.... and bonus points for it working on other platforms too ;-)<br><br>Thank you :-)<br>