Author Topic: How do I capture output from the "shell" slick-c function?  (Read 3930 times)

pmsteinm

  • Community Member
  • Posts: 78
  • Hero Points: 0
How do I capture output from the "shell" slick-c function?
« on: February 16, 2008, 01:00:35 am »
I've searched around this forum and haven't found anything that worked to solve this:

I'm calling a perl script from within a slick-c macro using the shell function:
  retCode = shell("/a/b/someScript.pl");

How to I capture the output of someScript in a Slickedit window? If I use concur_shell I can get stuff show up in the current buffer.  I'd really like the ability to have this stuff show up in the output window.  Is there a way to do this?

I'm running on AIX, slickedit 11.0.2.

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 281
Re: How do I capture output from the "shell" slick-c function?
« Reply #1 on: February 16, 2008, 01:50:52 am »
I'm using 'concur_command' to run something in the 'Build' window.
The 'Output' window can't be used for this purpose.
Example:
Code: [Select]
_command void ddir () name_info (','VSARG2_EDITORCTL)
{
   activate_build ();
   _str cmdline=get_env ("COMSPEC") " /c dir" " 2>&1";
   concur_command (cmdline, false, true, false, false);
}
Hope it helps,
HS2

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3715
  • Hero Points: 242
Re: How do I capture output from the "shell" slick-c function?
« Reply #2 on: February 18, 2008, 09:28:39 pm »
If the process buffer is not what you want.  Try _PipeShellResult().  It front ends some popen()-like calls.  I must admit I've never used it.

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: How do I capture output from the "shell" slick-c function?
« Reply #3 on: July 17, 2008, 10:24:21 am »
I'm interested in the functionnaly too. I have tested _PipeShellResult() function but only stdout is read. If the process only outputs on stderr, you will get an empty string back.
Is there any way to get output from a shell(cmd) call shown on the SE output window ?

hs2

  • Senior Community Member
  • Posts: 2725
  • Hero Points: 281
Re: How do I capture output from the "shell" slick-c function?
« Reply #4 on: July 17, 2008, 11:06:23 am »
In principle you could also retrieve the contents of the hidden '.process' buffer. I think '_open_temp_view()' could be an appropriate way to do that. If you launch a cmd similar to the way (2>&1) used in the example macro in my prev. posting both stdout/stderr are piped to the build window which displays the '.process' buffer. But it depends on your use case.
HS2

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3715
  • Hero Points: 242
Re: How do I capture output from the "shell" slick-c function?
« Reply #5 on: August 11, 2008, 05:11:30 pm »
The _PipeShellResult function only handles stdin and assumes one line of output.  We could use a better function which outputs stdin+stderr to a string or a view.  I guess we haven't had much need for this.  The "dos -e <cmdline>" Slick-C command redirects the output of a compile command to a file and then loads it and searches for errors.  It doesn't use the new _PipeProcess built-in.