cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

STDOUT from shell

GarethOakes
16-Pearl

STDOUT from shell

Hi there,

I've been writing a package for Arbortext Editor with the goal of a
lightweight integration with a source control system (subversion).

I'm using a simple menu which binds to some ACL scripts. These scripts
speak directly to the command-line client (svn.exe) to perform tasks
such as "get me a changelog", "check-in this file", "revert this file", etc.

I've got everything working great, except for one niggling problem. I'm
interested in how other people have interacted with the shell from
within ACL. See, I need to capture the output from the svn.exe tool.
I'm currently using the backquotes method as such:

$result = `svn.exe blah blah`

So the variable $result ends up being the STDOUT as returned by svn.exe.
The only problem is that the backquotes feature actually converts all
runs of whitespace (tabs, spaces, carriage returns) to a single space.
This means the returned output, eg. from a repository query, looks
pretty awful when I pop it up in a dialogue box.

Any input much appreciated 🙂

Cheers,
Gareth
2 REPLIES 2

Hi Gareth,

I guess you should redirect STDOUT to a file (svn.exe blah blah
>$tmpfilepath)
and then open the file for further processing.

HTH,

Olivier.

>>> - 13/04/06 7:56:31 AM >>>
Hi there,

I've been writing a package for Arbortext Editor with the goal of a
lightweight integration with a source control system (subversion).

I'm using a simple menu which binds to some ACL scripts. These
scripts
speak directly to the command-line client (svn.exe) to perform tasks
such as "get me a changelog", "check-in this file", "revert this file",
etc.

I've got everything working great, except for one niggling problem.
I'm
interested in how other people have interacted with the shell from
within ACL. See, I need to capture the output from the svn.exe tool.
I'm currently using the backquotes method as such:

$result = `svn.exe blah blah`

So the variable $result ends up being the STDOUT as returned by
svn.exe.
The only problem is that the backquotes feature actually converts
all
runs of whitespace (tabs, spaces, carriage returns) to a single space.
This means the returned output, eg. from a repository query, looks
pretty awful when I pop it up in a dialogue box.

Any input much appreciated Smiley Happy

Cheers,
Gareth

Hi Olivier & Gareth--

That's exactly how we do it. I even wrote a simple convenience function to handle it:

function windows_command(command) {
# executes the given command and returns any text sent to stdout
result = system("cmd /C " . command . " > $home\epicoutput.txt",1);
if (result != 0) { return "*** command failed ***" }
else {
$output = ";
$outputfile = open("$home\epicoutput.txt");
while (getline($outputfile,$line)!=0) {
$output = $output . $line;
}
close($outputfile);
system("cmd /C del $home\epicoutput.txt",1);
return $output;
}
}

Then, when I want to run a command and capture the output, I can just use something like windows_command("dir \foo\bar").

--Clay
Announcements