running external program in asp.net

D

dana livni

i'm new whis .net and i have a problome running external program in
asp.net

my goal is to run an exe file using asp.net
the file need to run on the server side becouse it insert data into a
DB located on the server.

please help me
 
M

Marina

Look at the Process class. You can basically create a new process object and
have it run a particular .exe.
 
S

Steve Caliendo

You can create a DLL in VB6.0 which does your DB stuff, and then add that
DLL to your references in your web application. I use this method quite
often. It's easy to do.

Steve
 
D

dana livni

i tried to do this:

<%@ Import namespace="System" %>
<%@ Import namespace="System.Diagnostics" %>
<%@ Import namespace="System.ComponentModel" %>

Dim detailes_Process As New Process()
detailes_Process.StartInfo.FileName=
"C:\Inetpub\wwwroot\asp.net\companysdetailes-test.exe"
detailes_Process.Start()

i don't get any errers but the exe file doesn't do his job.

what am i doing wrong?
 
A

Abhijeet Dev

Check the following:
1. If the behavior of ur application is independent of user executing it, in
this case aspnet is executing it.
2. [Depends on the application] If the application interacts with desktop i
mean if its a windows application, it may require u to allow IIS to interact
with desktop (in services.msc) and then run it using the logged on user
account (dynamic impersonation would do).. also, user must have a desktop
when running this application i.e. user must be logged on.

Abhijeet Dev
 
D

dana livni

i'm not sure, like i said i'm new at this.
the program that i tried to run is actually a perl script that i
compieled into an exe file.

the scrict approach the internet, (send a get command) parss the page
he gets back, and insert some data into a database.

when i tried to run notepad.exe i think it ran because i so it on the
procces list. but my script dosn't.

what sould i do?
 
A

Alvin Bruney [MVP]

you don't need to convert the script to an exe. If you have the perl windows
version installed, you can fire off the cmd window and then write the script
along with its arguments into the cmd window . I like this approach because
you can actually read the returned value from the script if you needed to,
setting up an ad hoc communication mechanism between your application and
the script.
Consider:

//create the temp table
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = @"cmd";
myProcess.StartInfo.UseShellExecute = false;

//we will use the standard out to communicate between programs
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;

myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;
sIn.AutoFlush = true;
StreamReader sOut = myProcess.StandardOutput;
sIn.Write("Perl " + @"d:\perlscripts\retail_merge_request.pl" + " Arguments
go here " + System.Environment.NewLine);
sIn.Close();

The effect of this is the same as if you navigated to a dos cmd prompt and
typed in
<< retail_merge_request.pl arguments go here >>
and then pushed enter

You can read the results if your script writes output like so
string results = sOut.ReadToEnd().Trim();

sOut.Close();
 
D

dana livni

it is a small thing but i'm sure how to do it.
your code is in c# but i write in vb, how to i change it?

thank you.


Alvin Bruney said:
you don't need to convert the script to an exe. If you have the perl windows
version installed, you can fire off the cmd window and then write the script
along with its arguments into the cmd window . I like this approach because
you can actually read the returned value from the script if you needed to,
setting up an ad hoc communication mechanism between your application and
the script.
Consider:

//create the temp table
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = @"cmd";
myProcess.StartInfo.UseShellExecute = false;

//we will use the standard out to communicate between programs
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;

myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;
sIn.AutoFlush = true;
StreamReader sOut = myProcess.StandardOutput;
sIn.Write("Perl " + @"d:\perlscripts\retail_merge_request.pl" + " Arguments
go here " + System.Environment.NewLine);
sIn.Close();

The effect of this is the same as if you navigated to a dos cmd prompt and
typed in
<< retail_merge_request.pl arguments go here >>
and then pushed enter

You can read the results if your script writes output like so
string results = sOut.ReadToEnd().Trim();

sOut.Close();

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
dana livni said:
i'm not sure, like i said i'm new at this.
the program that i tried to run is actually a perl script that i
compieled into an exe file.

the scrict approach the internet, (send a get command) parss the page
he gets back, and insert some data into a database.

when i tried to run notepad.exe i think it ran because i so it on the
procces list. but my script dosn't.

what sould i do?
 
M

MS News \(MS ILM\)

remove " ; " at end of lines and Dim as follows, the rest is the same
somewhat..

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
becomes....
Dim myProcess as System.Diagnostics.Process = new
System.Diagnostics.Process()

myProcess.StartInfo.FileName = "cmd"
myProcess.StartInfo.UseShellExecute = false
myProcess.StartInfo.RedirectStandardInput = true
myProcess.StartInfo.RedirectStandardOutput = true

myProcess.Start()
Dim sIn as StreamWriter= myProcess.StandardInput

etc..


dana livni said:
it is a small thing but i'm sure how to do it.
your code is in c# but i write in vb, how to i change it?

thank you.


"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
you don't need to convert the script to an exe. If you have the perl windows
version installed, you can fire off the cmd window and then write the script
along with its arguments into the cmd window . I like this approach because
you can actually read the returned value from the script if you needed to,
setting up an ad hoc communication mechanism between your application and
the script.
Consider:

//create the temp table
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = @"cmd";
myProcess.StartInfo.UseShellExecute = false;

//we will use the standard out to communicate between programs
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;

myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;
sIn.AutoFlush = true;
StreamReader sOut = myProcess.StandardOutput;
sIn.Write("Perl " + @"d:\perlscripts\retail_merge_request.pl" + " Arguments
go here " + System.Environment.NewLine);
sIn.Close();

The effect of this is the same as if you navigated to a dos cmd prompt and
typed in
<< retail_merge_request.pl arguments go here >>
and then pushed enter

You can read the results if your script writes output like so
string results = sOut.ReadToEnd().Trim();

sOut.Close();

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
dana livni said:
i'm not sure, like i said i'm new at this.
the program that i tried to run is actually a perl script that i
compieled into an exe file.

the scrict approach the internet, (send a get command) parss the page
he gets back, and insert some data into a database.

when i tried to run notepad.exe i think it ran because i so it on the
procces list. but my script dosn't.

what sould i do?
 
A

Alvin Bruney [MVP]

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
this is probably the only line that needs changing in vb

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
dana livni said:
it is a small thing but i'm sure how to do it.
your code is in c# but i write in vb, how to i change it?

thank you.


"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
you don't need to convert the script to an exe. If you have the perl windows
version installed, you can fire off the cmd window and then write the script
along with its arguments into the cmd window . I like this approach because
you can actually read the returned value from the script if you needed to,
setting up an ad hoc communication mechanism between your application and
the script.
Consider:

//create the temp table
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = @"cmd";
myProcess.StartInfo.UseShellExecute = false;

//we will use the standard out to communicate between programs
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;

myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;
sIn.AutoFlush = true;
StreamReader sOut = myProcess.StandardOutput;
sIn.Write("Perl " + @"d:\perlscripts\retail_merge_request.pl" + " Arguments
go here " + System.Environment.NewLine);
sIn.Close();

The effect of this is the same as if you navigated to a dos cmd prompt and
typed in
<< retail_merge_request.pl arguments go here >>
and then pushed enter

You can read the results if your script writes output like so
string results = sOut.ReadToEnd().Trim();

sOut.Close();

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
dana livni said:
i'm not sure, like i said i'm new at this.
the program that i tried to run is actually a perl script that i
compieled into an exe file.

the scrict approach the internet, (send a get command) parss the page
he gets back, and insert some data into a database.

when i tried to run notepad.exe i think it ran because i so it on the
procces list. but my script dosn't.

what sould i do?
 

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

Top