LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-15-2006, 02:24 PM   #1
armandino101
LQ Newbie
 
Registered: Oct 2006
Distribution: Ubuntu
Posts: 14

Rep: Reputation: 0
Perl - execute external programme


Hi,

I need to execute 'cvs commit' in my script. This should launch the default editor (emacs, vi, etc)so the user can enter a commit message, save and exit the editor. Then my script would take over again and iterate through the raw output of the commit:

I tried the following code but it doesn't work

Code:
open CVSOUT, "cvs commit @ARGV" or die "Error :$!";

while (<CVSOUT>) {
    # do
}
Can anyone point me in the right direction?
 
Old 12-15-2006, 03:34 PM   #2
mcummings
LQ Newbie
 
Registered: Oct 2006
Location: Fredericksburg, Va, USA
Distribution: Gentoo
Posts: 9

Rep: Reputation: 0
(as root) cpan Cvs. That'll install the Cvs module, which will probably be cleaner (and safer) than trying to do bundled system calls.

http://search.cpan.org/~rsoliv/Cvs-0.07/lib/Cvs.pm

(or just perldoc -f open)

Last edited by mcummings; 12-15-2006 at 03:35 PM.
 
Old 12-15-2006, 04:32 PM   #3
armandino101
LQ Newbie
 
Registered: Oct 2006
Distribution: Ubuntu
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks for the reply but is it doable without installing an extra module?
 
Old 12-15-2006, 04:32 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,965
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Quote:
Originally Posted by armandino101
Hi,

I need to execute 'cvs commit' in my script. This should launch the default editor (emacs, vi, etc)so the user can enter a commit message, save and exit the editor. Then my script would take over again and iterate through the raw output of the commit:

I tried the following code but it doesn't work

Code:
open CVSOUT, "cvs commit @ARGV" or die "Error :$!";

while (<CVSOUT>) {
    # do
}
Can anyone point me in the right direction?

The problem with those (vi, emacs) would be that they don't work
line-oriented in the terms perls readline...

I'd also suggest you use the CVS module.


Cheers,
Tink
 
Old 12-15-2006, 04:40 PM   #5
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
To answer your question, to send out a system call, use the system() function:
Code:
$commandToRun = "cvs commit @ARGV";
system($commandToRun);

Last edited by indienick; 12-15-2006 at 04:59 PM.
 
Old 12-15-2006, 06:38 PM   #6
sto237
LQ Newbie
 
Registered: Oct 2005
Posts: 8

Rep: Reputation: 0
And to look at the output of an external program, one way to do it is to open it with a trailing pipe:

open FOUT, "/bin/ls -l |";

print "Hi, $_" while (<FOUT>); # greet all files named by ls

But I second the "use the module" suggestion
 
  


Reply

Tags
cvs, perl, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
perl script to execute my a c executable on remote machin sharad Linux - General 5 12-14-2006 07:56 AM
Apache2 on Debian won't execute perl cgi scripts, have tried chmod, Options ExecCGI dewert Linux - Software 1 07-03-2006 12:44 PM
Apache 2 does not execute Perl! mesh2005 Linux - Networking 1 10-26-2005 10:51 PM
Perl won't write to or create external files. Decipher Programming 3 11-17-2004 06:49 AM
Why cant i execute a perl script dude4you Linux - Newbie 2 03-02-2004 05:50 PM


All times are GMT -5. The time now is 05:43 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration