How do you get vi to indicate that a file was not changed upon exiting (e.g. crontab -e)

How do you get vi to indicate that a file was not changed upon exiting (e.g. crontab -e)

Post by key ma » Wed, 25 Jul 2001 04:02:00



HPUX
If I use
crontab -e
 and do not make any changes the following message is displayed when
exiting vi:
"The crontab file was not changed."

How do you get vi to do this for any file you view?

 
 
 

How do you get vi to indicate that a file was not changed upon exiting (e.g. crontab -e)

Post by Ari Makel » Wed, 25 Jul 2001 06:07:38



> How do you get vi to do this for any file you view?

vi does not usually use those words, but it does warn you if you are
exiting without saving unless you use "q!".

Hmmm, lets try with an HP-UX-box:

% uname -a
HP-UX otso B.10.20 A 9000/785 <clip>

$ vi foo
foo
~
ESC-:q
No write since last change (:quit! overrides)

So, I say vi on HP-UX is not broken, at least not *that* broken. Now,
please tell us what's exactly your problem? I think it's something
else thaty you say it is.

--

#                                                 http://arska.org/hauva/ #

print "Navigare necesse est, vivere non est necesse - Pompeius\n";

 
 
 

How do you get vi to indicate that a file was not changed upon exiting (e.g. crontab -e)

Post by Chuck Geigne » Wed, 25 Jul 2001 04:48:29



> HPUX
> If I use
> crontab -e
>  and do not make any changes the following message is displayed when
> exiting vi:
> "The crontab file was not changed."

> How do you get vi to do this for any file you view?

Well, I threw this together; It seems to do what you want. Just name it
and then call it in lieu of vi (it calls vi internally) when editing a
file (only handles 1, modify if you need to do batches).

HTH

#!/bin/sh
if [ -f $1 ]; then
   cp $1 $1.sav
   vi $1
   CHK=`sum $1 $1.sav |cut -d " " -f 1|head -1`
   CHK1=`sum $1 $1.sav |cut -d " " -f 1|tail -1`
   if [ $CHK = $CHK1 ]; then
      echo "$1 has not changed."
   else
      echo "$1 has been modified."
   fi
   rm -f $1.sav
else
   vi $1
   echo "$1 did not exist before."
fi

--
Chuck Geigner ---------------------------------------
AIX Sysop
Milner Library, Illinois State Univ.
"Been borrowing Occam's shaving instrument since 1992
Haven't cut myself yet."_____________#rgvac==mongoose

 
 
 

How do you get vi to indicate that a file was not changed upon exiting (e.g. crontab -e)

Post by Ben.Altma » Wed, 25 Jul 2001 05:12:44




> > HPUX
> > If I use
> > crontab -e
> >  and do not make any changes the following message is displayed when
> > exiting vi:
> > "The crontab file was not changed."

> > How do you get vi to do this for any file you view?

> Well, I threw this together; It seems to do what you want. Just name it
> and then call it in lieu of vi (it calls vi internally) when editing a
> file (only handles 1, modify if you need to do batches).

> HTH

> #!/bin/sh
> if [ -f $1 ]; then
>    cp $1 $1.sav
>    vi $1
>    CHK=`sum $1 $1.sav |cut -d " " -f 1|head -1`
>    CHK1=`sum $1 $1.sav |cut -d " " -f 1|tail -1`
>    if [ $CHK = $CHK1 ]; then
>       echo "$1 has not changed."
>    else
>       echo "$1 has been modified."
>    fi
>    rm -f $1.sav
> else
>    vi $1
>    echo "$1 did not exist before."
> fi

What about:
      if cmp -s $1 $1.sav; then
          echo "$1 has not changed."
      else
          echo "$1 has been modified."
      fi

instead of your CHK bit?

 
 
 

How do you get vi to indicate that a file was not changed upon exiting (e.g. crontab -e)

Post by keym » Thu, 26 Jul 2001 05:23:48





> > > HPUX
> > > If I use
> > > crontab -e
> > >  and do not make any changes the following message is displayed when
> > > exiting vi:
> > > "The crontab file was not changed."

> > > How do you get vi to do this for any file you view?

> > Well, I threw this together; It seems to do what you want. Just name it
> > and then call it in lieu of vi (it calls vi internally) when editing a
> > file (only handles 1, modify if you need to do batches).

> > HTH

> > #!/bin/sh
> > if [ -f $1 ]; then
> >    cp $1 $1.sav
> >    vi $1
> >    CHK=`sum $1 $1.sav |cut -d " " -f 1|head -1`
> >    CHK1=`sum $1 $1.sav |cut -d " " -f 1|tail -1`
> >    if [ $CHK = $CHK1 ]; then
> >       echo "$1 has not changed."
> >    else
> >       echo "$1 has been modified."
> >    fi
> >    rm -f $1.sav
> > else
> >    vi $1
> >    echo "$1 did not exist before."
> > fi

> What about:
>       if cmp -s $1 $1.sav; then
>           echo "$1 has not changed."
>       else
>           echo "$1 has been modified."
>       fi

> instead of your CHK bit?

Thanks!
 
 
 

How do you get vi to indicate that a file was not changed upon exiting (e.g. crontab -e)

Post by Chuck Geigne » Sat, 28 Jul 2001 06:34:11



> What about:
>       if cmp -s $1 $1.sav; then
>           echo "$1 has not changed."
>       else
>           echo "$1 has been modified."
>       fi

> instead of your CHK bit?

Hehe, I was so bent on using a checksum to solve that I forgot the
simpler cmp.

Thanks Ben.

--
Chuck Geigner ---------------------------------------
AIX Sysop
Milner Library, Illinois State Univ.
"Been borrowing Occam's shaving instrument since 1992
Haven't cut myself yet."_____________#rgvac==mongoose

 
 
 

1. AfterStep does not save settings upon exit

I am stumped at something that happened to me today.  After adding
another menu to my AfterStep menu list and restarting the session, it
only stays there until next logon.  With my next logon, all my custom
menus are gone without a trace!  Could someone, please, let me know
what's happening here?  I hope, I won't have to launch all my programs
via terminal window... :-(

--
Bolek,
URL: http://www.bolek.com/

New Jersey, US

2. LINUX 1.2.x & secondary EIDE controller setup problem

3. how to indicate current vi mode?

4. htpasswd encryption for Windows

5. fix to crontab problem ("no changes made to crontab")

6. hdparm assitance

7. What DoS am I getting from nessus?

8. Xterm mouse problem

9. How to make vi not clear screen when exiting?

10. Changing Kernel - what am I doing wrong?

11. crontab -e or crontab -l is not functioning properly

12. crontab entries generate error message; problem with ownership of crontab file?

13. To crontab or NOT to crontab!!!