Monday, March 26, 2012

shell commands via ASP

Hi,
I need to run a few commands from the shell and display the output via ASP
(VB)

Any ideas?ASP or ASP.NET ?

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services

"George Lake" <g@.lake.com> wrote in message
news:%23AhDcw4cGHA.3352@.TK2MSFTNGP03.phx.gbl...
> Hi,
> I need to run a few commands from the shell and display the output via ASP
> (VB)
> Any ideas?
ASP.NET

"Swanand Mokashi" <swanandNOSPAM@.swanandmokashi.com> wrote in message
news:eZOlmi5cGHA.4912@.TK2MSFTNGP05.phx.gbl...
> ASP or ASP.NET ?
> --
> Swanand Mokashi
> Microsoft Certified Solution Developer (.NET) - Early Achiever
> Microsoft Certified Application Developer (.NET)
> http://www.dotnetgenerics.com/
> DotNetGenerics.com -- anything and everything about Microsoft .NET
> technology ...
> http://www.swanandmokashi.com/
> http://www.swanandmokashi.com/HomePage/WebServices/
> Home of the Stock Quotes, Quote of the day and Horoscope web services
>
> "George Lake" <g@.lake.com> wrote in message
> news:%23AhDcw4cGHA.3352@.TK2MSFTNGP03.phx.gbl...
>> Hi,
>> I need to run a few commands from the shell and display the output via
>> ASP (VB)
>>
>> Any ideas?
>>
>>
Here is a sample in C# -- you can use it in business layer and the output
below can be shown on the ASP.NET page

//------Start

/ #start a new process

Process p = new Process();

// #tells operating system not to use a shell;

p.StartInfo.UseShellExecute = false;

//#allow me to capture stdout, i.e. results

p.StartInfo.RedirectStandardOutput = true;

//Say DOS Command is [EXEPath] CONNECT anotherargument

p.StartInfo.Arguments = "CONNECT anotherargument";

p.StartInfo.FileName =[EXEPath];

//#do not show MSDOS window

p.StartInfo.CreateNoWindow = true;

//#do it!

p.Start();

System.Int32 _processID = p.Id;

//#capture results

string output = p.StandardOutput.ReadToEnd(); // this is the output from the
command

//#wait for all results.

p.WaitForExit();

p.Close();

//------End

HTH
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services

"George Lake" <g@.lake.com> wrote in message
news:%23n3jHn5cGHA.1320@.TK2MSFTNGP04.phx.gbl...
> ASP.NET
> "Swanand Mokashi" <swanandNOSPAM@.swanandmokashi.com> wrote in message
> news:eZOlmi5cGHA.4912@.TK2MSFTNGP05.phx.gbl...
>> ASP or ASP.NET ?
>>
>> --
>> Swanand Mokashi
>> Microsoft Certified Solution Developer (.NET) - Early Achiever
>> Microsoft Certified Application Developer (.NET)
>>
>> http://www.dotnetgenerics.com/
>> DotNetGenerics.com -- anything and everything about Microsoft .NET
>> technology ...
>>
>> http://www.swanandmokashi.com/
>> http://www.swanandmokashi.com/HomePage/WebServices/
>> Home of the Stock Quotes, Quote of the day and Horoscope web services
>>
>>
>> "George Lake" <g@.lake.com> wrote in message
>> news:%23AhDcw4cGHA.3352@.TK2MSFTNGP03.phx.gbl...
>>> Hi,
>>> I need to run a few commands from the shell and display the output via
>>> ASP (VB)
>>>
>>> Any ideas?
>>>
>>>
>>
>>
Ok,
I tested it in VB and returns nothing. Output is nothing.
I am using impersonation (as a domain admin).

Dim p As New Process
' #tells operating system not to use a shell;
p.StartInfo.UseShellExecute = False
'#allow me to capture stdout, i.e. results
p.StartInfo.RedirectStandardOutput = True
'Say DOS Command is [EXEPath] CONNECT anotherargument
p.StartInfo.Arguments = "CONNECT anotherargument"
p.StartInfo.FileName = "qwinsta.exe"
'#do not show MSDOS window
p.StartInfo.CreateNoWindow = True
'#do it!
p.Start()
Dim _processID As System.Int32 = p.Id
'#capture results
Dim output As String = p.StandardOutput.ReadToEnd()
' this is the output from the
p.WaitForExit()
p.Close()

"Swanand Mokashi" <swanandNOSPAM@.swanandmokashi.com> wrote in message
news:u4dNKt5cGHA.1276@.TK2MSFTNGP03.phx.gbl...
> Here is a sample in C# -- you can use it in business layer and the output
> below can be shown on the ASP.NET page
> //------Start
> / #start a new process
> Process p = new Process();
> // #tells operating system not to use a shell;
> p.StartInfo.UseShellExecute = false;
>
> //#allow me to capture stdout, i.e. results
> p.StartInfo.RedirectStandardOutput = true;
> //Say DOS Command is [EXEPath] CONNECT anotherargument
> p.StartInfo.Arguments = "CONNECT anotherargument";
> p.StartInfo.FileName =[EXEPath];
> //#do not show MSDOS window
> p.StartInfo.CreateNoWindow = true;
> //#do it!
> p.Start();
> System.Int32 _processID = p.Id;
> //#capture results
> string output = p.StandardOutput.ReadToEnd(); // this is the output from
> the command
> //#wait for all results.
> p.WaitForExit();
> p.Close();
>
> //------End
> HTH
> --
> Swanand Mokashi
> Microsoft Certified Solution Developer (.NET) - Early Achiever
> Microsoft Certified Application Developer (.NET)
> http://www.dotnetgenerics.com/
> DotNetGenerics.com -- anything and everything about Microsoft .NET
> technology ...
>
> http://www.swanandmokashi.com/
> http://www.swanandmokashi.com/HomePage/WebServices/
> Home of the Stock Quotes, Quote of the day and Horoscope web services
>
> "George Lake" <g@.lake.com> wrote in message
> news:%23n3jHn5cGHA.1320@.TK2MSFTNGP04.phx.gbl...
>> ASP.NET
>>
>> "Swanand Mokashi" <swanandNOSPAM@.swanandmokashi.com> wrote in message
>> news:eZOlmi5cGHA.4912@.TK2MSFTNGP05.phx.gbl...
>>> ASP or ASP.NET ?
>>>
>>> --
>>> Swanand Mokashi
>>> Microsoft Certified Solution Developer (.NET) - Early Achiever
>>> Microsoft Certified Application Developer (.NET)
>>>
>>> http://www.dotnetgenerics.com/
>>> DotNetGenerics.com -- anything and everything about Microsoft .NET
>>> technology ...
>>>
>>> http://www.swanandmokashi.com/
>>> http://www.swanandmokashi.com/HomePage/WebServices/
>>> Home of the Stock Quotes, Quote of the day and Horoscope web services
>>>
>>>
>>> "George Lake" <g@.lake.com> wrote in message
>>> news:%23AhDcw4cGHA.3352@.TK2MSFTNGP03.phx.gbl...
>>>> Hi,
>>>> I need to run a few commands from the shell and display the output via
>>>> ASP (VB)
>>>>
>>>> Any ideas?
>>>>
>>>>
>>>
>>>
>>
>>

0 comments:

Post a Comment