system(...) redirect output to file ?

R

Rebhan, Gilbert

Hi,

i use the system method on Windows like that =3D

Dir.chdir(CVSWORKSPACE) do
system("T:/cvsnt/cvs.exe -d :pserver:testuser@cvs:d:/cvsrepos/test
commit -m 'blabla'")
end

How to redirect the ouptut from a system call to a file ?

Like f.e. C:\>dir > Y:\output.txt in a cmd shell

I need to parse the output from=20
cvs -update command to get the new files before doing a commit.


Regards, Gilbert
 
H

Harry

How to redirect the ouptut from a system call to a file ?

system("dir > myfile.txt")

Harry
 
K

Kalman Noel

Rebhan, Gilbert:
I need to parse the output from
cvs -update command to get the new files before doing a commit.

output = `command here`

Note the use of backticks (`), and note that only the command's stdout is
redirected. For more complicated use there is IO.popen. Note furthermore
that ` is a method, which means that (hopefully) all you need to know can
be found via

ri '`'
ri IO.popen

Regards, Kalman
 
R

Rebhan, Gilbert

=20
Hi,

-----Original Message-----
From: Kalman Noel [mailto:[email protected]]=20
Sent: Monday, February 19, 2007 11:45 AM
To: ruby-talk ML
Subject: Re: system(...) redirect output to file ?

/*
output =3D `command here`

Note the use of backticks (`), and note that only the command's stdout
is
redirected. For more complicated use there is IO.popen.
*/

until now i redirected the output from cvs update command to a file,=20
format looks like =3D

? subfolder1/file4.txt
? subfolder1/file5.txt

and parsed it with =3D

open($deployserver<<'/cvsout.txt').each { |x|=20
newfiles<<'.'<<'/'<<x[2..-3]<<' ' }

to get all newfiles in a space separated string for the following
cvs add command

How to do that with the ` backquote method or IO.popen ?

f.e.

Dir.chdir(CVSWORKSPACE)
pipe=3DIO.popen(".../cvsnt/cvs.exe -d
:pserver:#{ENV["USERNAME"]}@cvsprod:d:/cvsrepos/test update")
??? how do i get the pipe contents into a space separated string ???


Regards, Gilbert
 
R

Rebhan, Gilbert

=20
Hi,

did it with =3D

newfiles=3DArray.new
Dir.chdir(CVSWORKSPACE)
pipe=3DIO.popen(".../cvs.exe -d
:pserver:#{ENV["USERNAME"]}@cvsprod:d:/cvsrepos/test update")
p pipe.readlines.each { |x|=20
newfiles<<'.'<<'/'<<x[2..-2]<<' ' }
puts newfiles.to_s
./subfolder1/file4.txt ./subfolder1/file5.txt=20

Recommended or is there a better way ?


-----Original Message-----
From: Rebhan, Gilbert [mailto:[email protected]]=20
Sent: Monday, February 19, 2007 2:01 PM
To: ruby-talk ML
Subject: Re: system(...) redirect output to file ?

=20
Hi,

-----Original Message-----
From: Kalman Noel [mailto:[email protected]]=20
Sent: Monday, February 19, 2007 11:45 AM
To: ruby-talk ML
Subject: Re: system(...) redirect output to file ?

/*
output =3D `command here`

Note the use of backticks (`), and note that only the command's stdout
is
redirected. For more complicated use there is IO.popen.
*/

until now i redirected the output from cvs update command to a file,=20
format looks like =3D

? subfolder1/file4.txt
? subfolder1/file5.txt

and parsed it with =3D

open($deployserver<<'/cvsout.txt').each { |x|=20
newfiles<<'.'<<'/'<<x[2..-3]<<' ' }

to get all newfiles in a space separated string for the following
cvs add command

How to do that with the ` backquote method or IO.popen ?

f.e.

Dir.chdir(CVSWORKSPACE)
pipe=3DIO.popen(".../cvsnt/cvs.exe -d
:pserver:#{ENV["USERNAME"]}@cvsprod:d:/cvsrepos/test update")
??? how do i get the pipe contents into a space separated string ???


Regards, Gilbert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top