Command Line Results 
Author Message
 Command Line Results

I'm attempting to write a web interface using VB and ASP to a system.  The
system already has a GUI and a set of command line programs.  I want to use
ASP on the server side to execute the command line programs and then use a
Visual Basic ActiveX Dll to parse out the resulting command line and return
HTML to the browser.  My delima is that I can't think of a clean way to get
the command line.  The only way I can think of is something like the
following:

Shell$("SomeProgram.exe > " & RandomTextFile)
Open RandomTextFile for output
sReturnString = SuperParser(RandomTextFile)
return sReturnString

obviously this is just psuedocode but you get the idea.  I think that I can
use pipes, either named or unnamed to do this and I won't have to do the
disk writes and cleanup.  To summarize.

How do I get the results of a command line program without using an
intermediate text file.

I have no problem with API calls.  Third party stuff would be OK but only as
a last resort.  I'd probably use the text file rather than the third party
stuff.

Thanks for your time and help.

Adam



Sun, 24 Feb 2002 03:00:00 GMT  
 Command Line Results
Are you familiar with VB's "command" function?

_______________________________________
Command Function
Returns the argument portion of the command line used to launch Microsoft
Visual Basic or an executable program developed with Visual Basic.

Syntax

Command

Remarks

When Visual Basic is launched from the command line, any portion of the
command line that follows /cmd is passed to the program as the command-line
argument. In the following example, cmdlineargs represents the argument
information returned by the Command function.

VB /cmd cmdlineargs

For applications developed with Visual Basic and compiled to an .exe file,
Command returns any arguments that appear after the name of the application
on the command line. For example:

MyApp cmdlineargs

Command Function Example
This example uses the Command function to get the command line arguments in
a function that returns them in a Variant containing an array.

Function GetCommandLine(Optional MaxArgs)
   'Declare variables.
   Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
   'See if MaxArgs was provided.
   If IsMissing(MaxArgs) Then MaxArgs = 10
   'Make array of the correct size.
   ReDim ArgArray(MaxArgs)
   NumArgs = 0: InArg = False
   'Get command line arguments.
   CmdLine = Command()
   CmdLnLen = Len(CmdLine)
   'Go thru command line one character
   'at a time.
   For I = 1 To CmdLnLen
      C = Mid(CmdLine, I, 1)
      'Test for space or tab.
      If (C <> " " And C <> vbTab) Then
         'Neither space nor tab.
         'Test if already in argument.
         If Not InArg Then
         'New argument begins.
         'Test for too many arguments.
            If NumArgs = MaxArgs Then Exit For
            NumArgs = NumArgs + 1
            InArg = True
         End If
         'Concatenate character to current argument.
         ArgArray(NumArgs) = ArgArray(NumArgs) & C
      Else
         'Found a space or tab.
         'Set InArg flag to False.
         InArg = False
      End If
   Next I
   'Resize array just enough to hold arguments.
   ReDim Preserve ArgArray(NumArgs)
   'Return Array in Function name.
   GetCommandLine = ArgArray()
End Function

_______________________________________

Craig S.

Quote:

>I'm attempting to write a web interface using VB and ASP to a system.  The
>system already has a GUI and a set of command line programs.  I want to use
>ASP on the server side to execute the command line programs and then use a
>Visual Basic ActiveX Dll to parse out the resulting command line and return
>HTML to the browser.  My delima is that I can't think of a clean way to get
>the command line.  The only way I can think of is something like the
>following:

>Shell$("SomeProgram.exe > " & RandomTextFile)
>Open RandomTextFile for output
>sReturnString = SuperParser(RandomTextFile)
>return sReturnString

>obviously this is just psuedocode but you get the idea.  I think that I can
>use pipes, either named or unnamed to do this and I won't have to do the
>disk writes and cleanup.  To summarize.

>How do I get the results of a command line program without using an
>intermediate text file.

>I have no problem with API calls.  Third party stuff would be OK but only
as
>a last resort.  I'd probably use the text file rather than the third party
>stuff.

>Thanks for your time and help.

>Adam



Sun, 24 Feb 2002 03:00:00 GMT  
 Command Line Results
I've looked at the command function but what I'm wanting is to be able to
get the results of the command.

For instance, if I type

dir *.* /s

I might get something like:
 Volume in drive C is NT_SYS
 Volume Serial Number is 6E37-1787

 Directory of C:\TEMP

02/21/99  03:00p        <DIR>          .
02/21/99  03:00p        <DIR>          ..
05/15/99  02:53p                     0 trb6.tmp
05/15/99  03:15p                     0 trb8.tmp
05/17/99  05:17p                     0 trbA.tmp
05/16/98  08:51p                56,320 opid2.dll
05/17/99  05:18p                     0 trbC.tmp
06/17/98  12:00a               254,005 msvcrt60.dll
05/17/99  05:24p                     0 trbE.tmp
05/18/99  09:23a                     0 trb21.tmp
05/30/99  06:41p                     0 trb81.tmp
06/02/99  07:59a                     0 icqC.tmp
06/02/99  07:15a                 1,531 r2h5.tmp
06/02/99  07:15a                     0 h2r6.tmp
06/05/99  08:26a                10,240 ~INS0363.~MP
05/31/99  10:28a        <DIR>          VBE
06/02/99  07:59a                    74 icqC.url
06/13/99  09:19p                     0 trb2D.tmp
07/25/99  10:31a                 1,536 ~DF41D.tmp
07/20/99  07:57p        <DIR>          MSE1.tmp
07/25/99  10:31a                     0 ~DF42C.tmp
08/24/99  08:49p                     0 trb2.tmp
08/24/99  08:52p                     0 trb4.tmp
08/24/99  08:53p                     0 trb7.tmp
08/24/99  08:54p                     0 trb9.tmp
07/25/99  01:20p                   263 error.log
08/24/99  08:55p                     0 trbB.tmp
08/24/99  09:01p                     0 trbD.tmp
09/08/99  10:25p                     0 ~DFAC2B.tmp
09/08/99  10:30p                     0 ~DF812.tmp
09/08/99  10:27p                 2,048 ~WRS0000.tmp
09/08/99  10:30p               308,696 mso37.tmp
09/01/99  05:01p                 2,950 acorsaw.id
09/02/99  08:53a                 2,675 dcorsaw.id
08/24/99  03:58p                 3,438 dmyers_test.id
08/26/99  08:46a                 4,220 itnotes0.id
09/02/99  08:52a                 3,426 ladmin.id
06/09/99  02:28p                 2,682 tmcguire.id
09/08/99  11:00p                     0 output.txt
              39 File(s)        654,104 bytes

 Directory of C:\TEMP\VBE

05/31/99  10:28a        <DIR>          .
05/31/99  10:28a        <DIR>          ..
05/31/99  10:28a               147,272 MSForms.EXD
               3 File(s)        147,272 bytes

 Directory of C:\TEMP\MSE1.tmp

07/20/99  07:57p        <DIR>          .
07/20/99  07:57p        <DIR>          ..
               2 File(s)              0 bytes

     Total Files Listed:
              44 File(s)        801,376 bytes
                             32,784,384 bytes free

I used the redirection command to put this file into a text file.  I'm
wanting to get this same information without
going thru the intermediate step of a text file.

I'd like my program to be able to work like the find command under NT (or
grep if you're more familiar with Unix).

so if I use the same command and then pipe it like the following....

dir *.* /s | find "acorsaw.id"

I would get the following output:

09/01/99  05:01p                 2,950 acorsaw.id

I hope that this makes more sense.  If not let me know and I'll try to
clarify a bit more.

Thanks for the answer, I'll let you know if I come up with anything in the
mean time.

Adam


Quote:
> Are you familiar with VB's "command" function?

> _______________________________________
> Command Function
> Returns the argument portion of the command line used to launch Microsoft
> Visual Basic or an executable program developed with Visual Basic.

> Syntax

> Command

> Remarks

> When Visual Basic is launched from the command line, any portion of the
> command line that follows /cmd is passed to the program as the
command-line
> argument. In the following example, cmdlineargs represents the argument
> information returned by the Command function.

> VB /cmd cmdlineargs

> For applications developed with Visual Basic and compiled to an .exe file,
> Command returns any arguments that appear after the name of the
application
> on the command line. For example:

> MyApp cmdlineargs

> Command Function Example
> This example uses the Command function to get the command line arguments
in
> a function that returns them in a Variant containing an array.

> Function GetCommandLine(Optional MaxArgs)
>    'Declare variables.
>    Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
>    'See if MaxArgs was provided.
>    If IsMissing(MaxArgs) Then MaxArgs = 10
>    'Make array of the correct size.
>    ReDim ArgArray(MaxArgs)
>    NumArgs = 0: InArg = False
>    'Get command line arguments.
>    CmdLine = Command()
>    CmdLnLen = Len(CmdLine)
>    'Go thru command line one character
>    'at a time.
>    For I = 1 To CmdLnLen
>       C = Mid(CmdLine, I, 1)
>       'Test for space or tab.
>       If (C <> " " And C <> vbTab) Then
>          'Neither space nor tab.
>          'Test if already in argument.
>          If Not InArg Then
>          'New argument begins.
>          'Test for too many arguments.
>             If NumArgs = MaxArgs Then Exit For
>             NumArgs = NumArgs + 1
>             InArg = True
>          End If
>          'Concatenate character to current argument.
>          ArgArray(NumArgs) = ArgArray(NumArgs) & C
>       Else
>          'Found a space or tab.
>          'Set InArg flag to False.
>          InArg = False
>       End If
>    Next I
>    'Resize array just enough to hold arguments.
>    ReDim Preserve ArgArray(NumArgs)
>    'Return Array in Function name.
>    GetCommandLine = ArgArray()
> End Function

> _______________________________________

> Craig S.


> >I'm attempting to write a web interface using VB and ASP to a system.
The
> >system already has a GUI and a set of command line programs.  I want to
use
> >ASP on the server side to execute the command line programs and then use
a
> >Visual Basic ActiveX Dll to parse out the resulting command line and
return
> >HTML to the browser.  My delima is that I can't think of a clean way to
get
> >the command line.  The only way I can think of is something like the
> >following:

> >Shell$("SomeProgram.exe > " & RandomTextFile)
> >Open RandomTextFile for output
> >sReturnString = SuperParser(RandomTextFile)
> >return sReturnString

> >obviously this is just psuedocode but you get the idea.  I think that I
can
> >use pipes, either named or unnamed to do this and I won't have to do the
> >disk writes and cleanup.  To summarize.

> >How do I get the results of a command line program without using an
> >intermediate text file.

> >I have no problem with API calls.  Third party stuff would be OK but only
> as
> >a last resort.  I'd probably use the text file rather than the third
party
> >stuff.

> >Thanks for your time and help.

> >Adam



Mon, 25 Feb 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Command-line compile, result throws error

2. use the result of the VBS for other application under the command line

3. Piping results of command line call to file from ASP

4. How do you execute a command-line program, and return the results into a variable

5. Capture text results from command line

6. Help with Win 95 screen saver command line - command line.zip [1/1]

7. Using Scripting.Shell Exec command to capture the results of a SFTP ls command

8. Running command-line commands through Access ?

9. Command-Line arguments using Command()

10. Win32 Code to Hide When You Run Command-Line Commands

11. How to execute a command line command from a *.HTA

12. Sleep command and running a command line in VBScript

 

 
Powered by phpBB® Forum Software