I have a directory full of DICOM on a linux file server. I have the directory mapped as a network drive and have created a c# console application for modifying the DICOM tags, modifying DICOM tags is something I must do before I can import to our database.
When I am in the server I can run the following to import everything from this directory to my database:
for x in `ls -d1 *`;
do
dcmbase_import -U p_mfdid1 -n -l info -i "$x:spiromics:file:H:SPIROMICS";
done
I would like to know if there is a way that I can run the above code from within the c# application. For instance, is there a way to access the linux file server and execute a shell script?
Currently I have to run my c# application to change heads and then manual access the server and run the shell script. I would love to have this all encompassed in one application so that I could run it at the end of the day and have it processing and importing over night.
You can't run the shell script over the network share as that would run it on your local machine and you need to run it on the Linux machine.
The common method for executing code remotely is by running it with SSH or invoking with RPC. I would avoid RPC if possible because even though it's more powerful it also needs more complicated setup.
From Karl-Johan Sjögren's answer on this question, C# send a simple SSH command, I was able to find a git project for SSH calls in .NET as well as a small stub that could get you started. You would change hostnameOrIp
to your Linux server, and change the command to be run to your script.
using (var client = new SshClient("hostnameOrIp", "username", "password"))
{
client.Connect();
client.RunCommand("etc/init.d/networking restart");
client.Disconnect();
}