For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2005 > Returning to my program after exiting vi.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Returning to my program after exiting vi.
Harold Castro

2005-03-07, 3:58 pm

Hi,
I wrote a script with a line,
system('vi ./config.txt');

which when encountered by the perl compiler, pops up
the vi editor and open the config.txt in the current
directory. What if I would just want the user the view
the very long text file, let's say, a list of
something, and his answer to my programs first line of
input is one of those lines contained in config.txt.
When perl launches the vi editor, it simply closes my
program and switch to vi, is it possible not to close
my program when vi launches and after closing (:q!) vi
would then return in my program with a prompt like,

You have just seen the rest of the choices. Enter one
here:


Do you know how it is done?

Thanks!







__________________________________
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web
http://birthday.yahoo.com/netrospective/
Rathna N

2005-03-07, 3:58 pm

You should be able to do it, by waiting for the return value.
Ex:
viRetValue=system("Comnnad String");
or
viRetValue = `<Comand Stirng>`;

--
Regards,
Rathna.

On Sun, 6 Mar 2005 23:07:19 -0800 (PST), Harold Castro
<b0ydaem0n@yahoo.com> wrote:
> Hi,
> I wrote a script with a line,
> system('vi ./config.txt');
>
> which when encountered by the perl compiler, pops up
> the vi editor and open the config.txt in the current
> directory. What if I would just want the user the view
> the very long text file, let's say, a list of
> something, and his answer to my programs first line of
> input is one of those lines contained in config.txt.
> When perl launches the vi editor, it simply closes my
> program and switch to vi, is it possible not to close
> my program when vi launches and after closing (:q!) vi
> would then return in my program with a prompt like,
>
> You have just seen the rest of the choices. Enter one
> here:
>
> Do you know how it is done?
>
> Thanks!
>
> __________________________________
> Celebrate Yahoo!'s 10th Birthday!
> Yahoo! Netrospective: 100 Moments of the Web
> http://birthday.yahoo.com/netrospective/
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>

Vladimir D Belousov

2005-03-07, 3:58 pm

That's right, but you should better use

my $viRetValue = system("command", "string");

In this case the command interpreter will not be used and that is more safe.

Rathna N wrote:

>You should be able to do it, by waiting for the return value.
>Ex:
>viRetValue=system("Comnnad String");
>or
>viRetValue = `<Comand Stirng>`;
>
>
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com