How to pass commands/scripts to Linux servers from ASP.NET - c#

We are trying to pass commands or shell scripts execution to Linux server from ASP.net.
For example, if we pass command ls from ASP.NET to Linux server, then it must provide a list of files present in the respective path to ASP.NET as output.
Can anyone share the idea how we can achieve this?

telnet and other remote shell protocols are there for this.
Note: without proper security considerations it is very dangerous idea.

If you only need to access to the file system, consider using Samba. You can mount the remote file system to the Windows machine.
Another possibility is to access the files through FTP.

Related

c# Transfer file from remote machine to terminal server

I am creating an app that will be used with terminal services, and I have created a explorer that will allow me to transfer files. this is first of all only on local machine. Is there a way that will allow me to connect to the remote machine access their common library. that would allow them to choose desktop and Documents folders.
I have been trying to get the IP address of the remote machine by Code Projects Grabbing Information Of Terminal Services. I guess I'm really at a loss of words here, I'm not sure where to begin to start this process. any help or Ideas links would be very helpful.
Thanks so much!
Where is your file? In the net folder, or not? Can you install serviceses on target machine?
You can use Process.Start method in combination with Mark Russinovich utilities or powershell remoting.

FileDialog with Remoting C#

I need to develop an app in C# that is like the Restore Database at SQL Management Studio.
It's basically a FileDialog that remotely shows the files/folder on the server.
I think its pretty simple, but since I'm starting developing apps using Remote (.NET) I need some help.
Of course I'm not asking to have a ready-to-go code, I would appreciate some tutorials and how to start developing things remotely and using Windows Form.
Thanks !
Leo
That depends on the network access you're going to have to the remote machine. If you have access to the file system, all you need to do is point the regular file dialog to the right network path.
If you can't reach the remote machine's file system, you'll need to create an agent that runs on that machine and offers access to the files. You can do that, but unless you're really careful you're going to introduce a major security hole. Instead, you can just enable the regular Windows network file access.

C# Remote application execution

I'm trying to create some sort of remote application execution programs. The situation is that I have a script on a remote pc that I need to execute. Ideally I could do with being able to tell this remote pc to execute this script as though I was at it locally.
If possible it would be executable without the need to login to the pc (such as sending login details etc). I'm going for using .net c#.
The best code is code that you don't have to write yourself. Take a look at PSExec from Microsoft (SysInternals). Assuming that you have common credentials with the remote machine (either by virtue of a domain login or the same password and username), it should "Just Work".
Windows Management Instrumentation (WMI) allows you to do just that. If you need .NET bindings for it, they are in the System.Management namespace
I WOULD GO with what Rob or Daniel suggested, but if you want to do something dirty (don't) you could write a small service that you'd register on the remote PCs that would just watch for a specific trigger. For example, the service could periodically check a network drive for a file, a database for some parameters, etc.
But as I said previously, this is something I would do if I'd want something really temporary and wouldn't want to spend time to learn how to do it properly.

Copy a file on a network path without transfering it to my own machine

If my .NET client uses System.IO.File.Copy to copy a file from \server1\share1\file1.txt to \sever1\share2\file2.txt, the file's data get read down to the client and then written back up to the server.
Is there an easy way to speed up things a bit by putting a process on the network-machine that realy does the copying?
I dont look for advice on programming such a service. I would rather find the tool or windows-functionality that already does this.
This sounds like a job for telnet or ssh, but these can be a pain to set up. I recommend you look at PsExec from microsoft which allows you to execute programs on a remote machine. You could simply use the copy program found in system32 through PsExec.
There is no need to create your own program to do this, just use the command line tools found on the target machine.
Almost certainly. I can think of a couple basic ways to do it:
Create a simple console applicaton that takes the source and destination paths/filenames, and performs a File.Copy(). Place it on the remote machine in a known location. Then invoke the process on the remote machine using PsExec. Your client app must be running in full trust in order to invoke a process programmatically, and the user running the app must have permission to run programs on the remote server.
Create a simple web method that again takes the source and destination and performs the copy. This requires setting up IIS on the network server with the requisite permissions to perform file access outside of the IIS "sandbox". However, it requires fewer client code permissions.
FYI CopyFileEx already does this if your client and server are Vista and later. So, not point in duplicating any of that effort in that case.
-scott

FTP Login using Windows Credentials

We have a C# windows application that needs to be able to connect to a server on a network, download and save a file to a specified location.
We can not use a web service as we can not assume that our clients will have IIS on their server.
The way that I am considering doing it is to FTP onto the server and download the file. I can write the code to connect to the server and located the file but I have 2 questions.
Is there a way of using the windows credentials to FTP on to the remote server? (I understand that I cannot directly get the user's password).
Is there a better way of getting the file from a server other than ftp-ing on to it?
Thanks for the advice.
I'm assuming that a network share isn't an option (perhaps an external site etc).
Note that IIS isn't the only way of hosting a web-service. With WCF, you can use a console exe or a windows service to host the WCF service, which would allow you to run WCF on the server without any mention of IIS. See here. Then all you need is line-of-sight to the server, and some code that returns the file (or chunks of it, or a stream of it).
Depending on the size of the file (e.g. if it is less than 4MB) - you might consider leveraging a public MSMQ mechanism.

Categories

Resources