Problem with psftp in .NET.

G

Guest

Hello: I use a W2000+ASP.NET , and I want to execute an external command from
a .NET DLL, the line is something like this:

psftp.exe root172.168.0.108 -pw root -b bat.txt

psftp is a secure ftp console program, and the bat.txt file contains all the
necessary commands to get a file from the server and quit the session.

If I execute this line from a console, everything goes well, connects to the
server, gets the file and return to the console, but I'm trying to do the
same from a DLL or ASPX page in various ways, popen, ` `, exec...

Always is the same, it seems it does nothing, and I'm sure the psftp.exe and
bat.txt files are in the same dir of the script.

Any idea?
 
C

Christopher Reed

If you're trying to launch a program from an ASP.NET application, keep in
mind that you are asking the server to run this application, not the client.
Any commands that are executed in the server-side code is run on the server.

Additionally, why do you want to run an EXE from a web application. From a
security perspective, this is very ill-advised.

What do you really want to do?
 
G

Guest

Thanks for your response.

Christopher Reed said:
If you're trying to launch a program from an ASP.NET application, keep in
mind that you are asking the server to run this application, not the client.
Any commands that are executed in the server-side code is run on the server.

Yes, I know its run on server side.
Additionally, why do you want to run an EXE from a web application. From a
security perspective, this is very ill-advised.

What do you really want to do?

I am automating the transfering files from server to clients PSFTP site.
'psftp.exe' is a command line program for transferring files.

My doubts:

1) As i told before that command is running fine through command prompt and
also working fine in .net console application. But it is not working in web
application. May be some security settings are blocking the connection to
site.

2) Web application is accessing the system as a ASPNET user not the
administrator user. When we run the command through command prompt we are
administrator users so it is working fine. May be there is a problem with
this type of user access.

Please give your valuable information,
Thanks.
 
C

Christopher Reed

The problem with trying to run an executable from an ASP.NET application is
that you are opening a potentially hazardous security issue with this
application, especially if this runs over the Internet. In general, it is
truly unadvisable to perform this type of function.

Now, if your goal is copy files from server to client's FTP site, then why
not use the functionality available in .NET. If you're using .NET 2.0,
there are FtpWebRequest and FtpWebResponse classes that can provide similar
functionality. In .NET 1.1, you can use the WebRequest and WebResponse
classes to create FTP functionality.
 

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