Invoking (interactive) vi editor 
Author Message
 Invoking (interactive) vi editor

(Environment: Sun SPARC, perl4, SunOS, soon to be Solaris 2.4)

I need to invoke vi from within a Perl script.  I know that I can do
this by executing a unix command to start up a new window, but I would
much prefer to use the window that is executing the Perl script.  (This
would be similar to how the unix command "crontab -e" works.)

I checked thru the FAQ, but couldn't find anything that might help.

Can anyone help?

+======================================================+
  Kenneth R Yates (but you can call me ... Ken)
  Pacific Northwest National Laboratory 509-375-2390

+======================================================+



Sun, 07 Jun 1998 03:00:00 GMT  
 Invoking (interactive) vi editor
[mailed and posted]
: (Environment: Sun SPARC, perl4, SunOS, soon to be Solaris 2.4)

: I need to invoke vi from within a Perl script.  I know that I can do
: this by executing a unix command to start up a new window, but I would
: much prefer to use the window that is executing the Perl script.  (This
: would be similar to how the unix command "crontab -e" works.)

Did you try:

        system 'vi', $file;

It has always worked for me.  In fact, if you look in the Camel
book, it suggests popping the user into an editor instead
of prompting yourself.

I used to use something this all the time:

        ($prog = $0) =~ s:.*/::;
        $EDITOR = $ENV{'VISUAL'} || $ENV{'EDITOR'} || 'vi';
        $form = "/tmp/~$prog.$$";
        system ('cp', 'myblankform', $form)
                && die "Couldn't copy blank to $form: $!\n";
        system $EDITOR, $form;
        &process($form);
        unlink $form;

Regards,
--
Mike Heins                                                    ___       ___
                                    Internet Robotics        |_ _|____ |_ _|
Few blame themselves until they     131 Willow Lane, Floor 2  | ||  _ \ | |
have exhausted all other            Oxford, OH  45056         | || |_) || |
possibilities.                                               |___|  _ <|___|



Sun, 07 Jun 1998 03:00:00 GMT  
 Invoking (interactive) vi editor

Quote:
> (Environment: Sun SPARC, perl4, SunOS, soon to be Solaris 2.4)

> I need to invoke vi from within a Perl script.  I know that I can do
> this by executing a unix command to start up a new window, but I would
> much prefer to use the window that is executing the Perl script.  (This
> would be similar to how the unix command "crontab -e" works.)

Am I miss understanding your question, but why won't
  system("/usr/ucb/vi $file");
do what you want?

Frank Stutzman
Stutzman Consulting           (on contract to Bay Networks)


http://www.stutzman.com
(my English teacher warned me about abusing parentheses)



Sun, 07 Jun 1998 03:00:00 GMT  
 Invoking (interactive) vi editor

Quote:

>(Environment: Sun SPARC, perl4, SunOS, soon to be Solaris 2.4)

>I need to invoke vi from within a Perl script.  I know that I can do
>this by executing a unix command to start up a new window, but I would
>much prefer to use the window that is executing the Perl script.  (This
>would be similar to how the unix command "crontab -e" works.)

>I checked thru the FAQ, but couldn't find anything that might help.

>Can anyone help?

>+======================================================+
>  Kenneth R Yates (but you can call me ... Ken)
>  Pacific Northwest National Laboratory 509-375-2390

>+======================================================+

This works for me:
system ("exec >/dev/tty </dev/tty ; \${EDITOR:-vi} $tmp ");

--
+---------------------------------------+-----------------------------------+
| Stuart Poulin                         | Phone: 206 882 5211 (Direct)      |
| Applied Microsystems Corporation      |        206 882 2000               |



Tue, 09 Jun 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Interactive program with command line history/vi mode--help needed

2. Difference between Notepad and Vi (text editor)

3. invoking interactive edit

4. Interactive Editor with Perl Power?

5. Invoke an editor

6. How to invoke the Unix VI cmd from perl script to move around in a file.

7. "perl aware" vi editor?

8. hooks into vi - editing macros

9. call vi from perl

10. call vi from perl

11. Error within vi with perl prog

12. debugging perl from vi

 

 
Powered by phpBB® Forum Software