Running perl script from asp.net application deployed on IIS 7.5
I have a very urgent requirement. I have a ASP.net application on framework 4.0 done in MVC architecture. In the application I am calling a Perl script to copy data from MySQL to SQL Server 2010 in the backend. When I run the application from Visual Studio 2010, the Perl script runs successfully and the data is copied. But when I deploy the same application on IIS 7.5, it does not show any change or the Perl scipt does not run. I tried printing each step of the code and found all the paths are coming correct. The perl script is to be run via a batch file.
Below is the code to start the process which runs a batch file which in turn runs the Perl script:
string strPath = string.Empty;
string strDirectory = string.Empty;
try {
strPath = "/k " + ConfigurationManager.AppSettings["UploadTLInfo"];//Path of the batch file comes from here
strDirectory = ConfigurationManager.AppSettings["WorkingDirectory"];
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe",strPath);
psi.U开发者_如何学运维seShellExecute = false;
psi.WorkingDirectory = strDirectory;
//psi.CreateNoWindow = true;
//psi.WindowStyle = ProcessWindowStyle.Hidden;
Process p = new Process();
p.StartInfo = psi;
p.Start();
} catch (Exception ex) {
throw ex;
}
Most probably, your issue will be related to user permissions - when you run from VS, you are probably using ASP.NET Dev server and it users current user's credentials while when you run from IIS, it would be using NETWORK_SERVICE (or similar system users) that may have limited permissions causing the issue. Another (but unlikely) issue can be that batch file and/or pearl might be relying on some environment variable that are not defined at machine level etc.
One of the solution would be to run the process impersonating another user that has specific permission and/or environment (see this to run process as another user).
精彩评论