SCP Command in Solaris to file transfer from c# - c#

Is There any way to do following in C#.NET or JAVA,
Get list of files from specific directory of Another pc having solaris OS and transfer file using SCP to another pc which have also solaris OS.
Actually i am thinking about creating front-end in asp.net to transfer backup from Live to backup server and get information about backup.
I even this is possible or not, but I wan't to clear my confusion on this.
Please give me your suggestion.

C# or any other .NET language is specific for Windows and won't run on anything but Windows. So forget about .NET languages. For this type of task I would definitely use Java if you insist on using a programming language at that level.
From Java you can use JSch library. It can do SCP from within Java. Here's is one example.
However I must say that most people that are familiar with Unix/Linux would probably simply do this task from within a scripting environment. Heck it can be done from Bash if you like.
Regardless of your choice of tool/prg.language you'll also have to decide if your doing PUSH or PULL. It seems from your posting that you are most keen on doing a PULL. There's no right or wrong answer on PUSH vs PULL.

Related

Run C# File on the internet like a CGI File

I have a Visual C# project on my computer and I would like my users to be able to interact with it through a web browser. I've done my research, and I understand that I will probably use CGI to do this.
However, while I have been able do this with .pl and .cpp files, i can't figure out how to to it with C sharp (.cs) files. Can anyone explain how I would do this?
EDIT: If there is an alternate solution wherein the webpage communicates my C# program as a back-end program, that works, too.
UPDATE: After cancelling with my hosting provider and setting up a home-based web server (windows), I finally got the C# file to run as CGI. Thanks to everyone for your help!
You've got to give us some context ... why wouldn't asp.net be an option? If you simply don't want to run in the context of IIS, you could simply write a windows service (and expose WCF services, or even raw sockets if that's what you need).
edit: in response to the recent comment about the server being UNIX, you can use MONO to run .net code on that server: http://www.mono-project.com/Main_Page
You can either use something like mod_mono or if you'd prefer something different, you can look at manos de mono
First, I assume you have the Mono project compiler and runtime environment installed on your system.
CGI takes place entirely via standard input and standard output. (This is one reason why it is so easy to write CGI scripts in Perl, Python, Ruby, etc. You just start reading standard input as usual, parse the variables, and write whatever output you want the client to see.) Don't forget that you're responsible for the entire header, including Mime type.
If you need something that performs faster than CGI's constant fork(2)+execve(2) re-starting your CLR over and over again, you can implement the FastCGI protocol (at least, I didn't see a C# implementation on the Wikipedia page) yourself using sockets and start your CLR once only, so you have some reasonable performance. (I seem to remember Nat being passionate about the Mono process start time being "fast enough" to use it for interactive commands, so perhaps a lightly-loaded server won't have any trouble with plain old CGI interface.)

Wlan information in mono on linux

I am working on a project that will run on a small linux platform. All applications on the system must be written in c# that will be executed via mono. But that is causing me some problems with the network information port. All the examples I have been able to find on the topic on the internet is for .net, and it seems that the WlanInterface module is not implemented in mono.
So the simple question is then, how do I get information such as ssid, rssi, available APs, and its like in mono on linux? Is there a simple way, or do I have to write a service object in e.g. c++ or java to get the information?
damn, not what I was hoping to hear :)
Anyway, I found another solution I will try to pursue. Since the machine has got gnome on it, hijacking the information from the network manager via dbus could be the solution. This might also be a good idea, since I would like to receive an event when connection is lost.
I would still like to hear comments both on this idea, MarkR's idea and any other alternatives.
You can invoke the command line utilities and parse their output via a pipe or something e.g.
iwconfig
iwlist
etc which will ship with a wifi-enabled Linux system.

Implementing an SNMP Reporter (agent) in C# (must run on Mono)?

I am attempting to implement some additional statistics gathering in a C# server application - I have about 20 or so variables I'd like to be able to report to network monitoring tools; so I am assuming (hopefully correctly) that SNMP is the correct way to go.
There are however two problems:
The application is an open source server that cant include proprietary components, and
It needs to run on Mono under *nix environs as well as Windows via .NET.
The "#SNMP" library at http://sharpsnmplib.codeplex.com/ appears to be a promising solution - but there are no samples I can find; and my knowledge of SNMP is lacking.
Does anyone here have any (quick) examples of reporting data via SNMP? (ideally using a library under the LGPL, X/MIT, BSD or Zlib licenses)
Help much appreciated
Edit:
The problem appears to be a lack of libraries capable of acting as SNMP servers, if anyone is aware of any - this would probably solve the problem nicely.
Edit #2:
Basically I'm looking for a SNMP server library or sample reference implementation.
As the author :) I suggest you check out TestAgent sample. It can send out TRAP or INFORM messages to the IP address you specify.
Note that this is a tiny sample, which does not reveal all powers of SNMP.
#SNMP source comes with some samples (they're actually tests, but one can have an idea about how it works).
Another thing you could try is send your snmp queries calling directly the snmpget executable with the Process class. It's not the best way, but it could work (I've used this kind of approach with another language).

C# or Python for my app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have the task of developing an application to pull data from remote REST services and generating Excel reports. This application will be used by a handful of users at the company (10-15). The data load can reach 10,000-200,000 records. I have been debating whether to use Python or C#...
The only reason I am considering Python is because I am familiar with it and it would be less of a risk.
Personally I want to try use C# since this would be a good opportunity to learn it. The application is not too complicated so the overhead of learning it won't be too much... I think.
Are there any issues with C# that I should be concerned about for this type of program? The users run Windows XP... would users not having .NET installed be a major concern?
Thanks in advance.
EDIT:
I guess I need to stress the fact that the end users should be able to run the application without installing additional libraries/frameworks.
Why not IronPython which merges the two worlds together?
If you want to learn C# and you don't have such a limited time constraint, now might be a good time to try it. Also, though I haven't done Excel work with either Python or C#, I would expect it to be easier to work with Excel files with a Microsoft product rather than Python. If you're just dumping data in CSV format to a file, though, either Python or C# will work fine.
If you want to try something even crazier, you can use IronPython such that you'll have .NET resources available but you can still write in Python.
I would normally say, use what you know.
However, here you may have some performance issues using an interpreted language. I, myself, would use C#. If you want to learn it, now is as good of a time as any.
However, if your own cost/benefit analysis reveals that you would be better off in python, use that.
.NET will be required for C# on windows, but you can use the .NET Client Profile to make the install pretty painless.
I realize this is an old post but I guess I have some pertinent information for anyone coming across this in more recent times, as I have.
The Python library, Openpyxl has worked well for me for manipulating and creating excel files in my desktop based automation scripts.
http://openpyxl.readthedocs.io/en/default/usage.html
It is accessing the file directly from my understanding, unlike the Interop technique in c#. So wherever it runs, you wouldn't need Excel installed. If you're trying to get something on a server it might be an issue getting a licensed copy of Excel or ensuring it exists if your user is running this locally.
Using C# you have the full features of visual studio to help code, such as the code completion, debugging tools and error highlighting. However you can get most of that with Python in Visual Studio, though I've found it more complicated trying to get the right version of python tied to the project and whatnot.
In C# you can easily compile an executable whereas I believe you'll need to mess with loading some Python libraries to get close to a similar local executable with dependencies comparable to the C# output.
If the users have to install a C# client then not having .NET installed would be an issue. You can package the installer so it downloads the .NET runtime, but depending on what features you use it could be quite a big download.
If your application is web based then all the C# code runs on the server and just delivers HTML to the browser so whether .NET is installed or not shouldn't matter.
Integration with Excel will almost certainly be simpler from C#. Given the requirements "Windows only" and "Integrates with Excel", it would seem a simple choice that C# is better suited to this individual problem.
And, no, users' not having .NET is not a concern compared with Python as the alternative. The Dot Net framework is a standard part of Microsoft Update. In contrast, Python will almost certainly not be there on the average end users' machine. In your case, with an internal app, that last point might not matter of course.
If you are doing any kind of HTTP work with C# make sure you take a look at the new HttpClient library that is in WCF REST Starter Preview2. Ignore the name of that download, the HttpClient part can be used independently of WCF.
It is a WAY better client than just using HttpWebRequest.
If you do a web based application not having installed .NET in the client machine wont be a problem .. but I suppose you dont want to try both C# and web development at the same time
It is easy with Python to pull data from a web server, parse the JSON or XML, and generate some kind of report. If you need really good Excel integration (for example, your output is supposed to be an Excel spreadsheet that includes numerous graphs) C# might be better, but Python is still possible; there is PyExcelerator for writing rich spreadsheet files, and there is Python support for COM if you want to use COM to talk to Excel.
With Python it is also very easy to make a stand-alone executable, for example with py2exe.
This sounds like a batch tool, one that won't have a GUI; I think I would write it in Python if I were you, unless I really wanted a fun project to help me learn C#. But anything with a GUI, C# is probably better. (I haven't done GUI development with Python, but I have seen comments here and elsewhere that the performance of Python GUIs tend to be slow.)
The answer probably has more to do with the circumstances than the question of which is the better language for the task at hand.
If you have no prior C# experience, it's probably not a good idea to jump into it now and learn it as you go along. Syntax differences are trivial to learn, mastery is defined by knowing the dirty details and how to use the language's strengths to get the job done.
If you have plenty of time and starting over a lot is NOT an issue, or you have experience with a language that is paradigmatically very similar to C# (say, Java or C++), you could probably afford to take the risk and adapt to the new language very quickly.
If you don't care about efficiency (e.g. it's a pet project, you don't care much about your job or efficiency simply isn't important), try C# just to learn something new (always a good thing) or stick to Python to make sure you won't have to adjust your thinking too much (always a source of vulnerabilities and misunderstandings).
If you definitely want to use C#, you should play around with it in your "free time" (not necessarily at home, but preferably at work when there's nothing else to do) and thus build a skillset you can use once you have to start with the actual project. This way you'll already be familiar with the paradigm (to use the term loosely) and encounter less problems where they count.

Filter TCP Packets in C#

I am writing an application where all the request to the internet should go from it like in firewall. so that i can block the request for a particular website. In my case the program will be running on the same machine. I have tried the promiscous method but using that we can only capture all the packets comming and going from the machine,
The easiest way to do it is probably to write a Layered Service Provider (LSP). There is an example in the Microsoft SDK on developing LSPs as well. Not as secure as a driver type firewall setup, but a lot easier to implement.
There's "probably" a way to do it with C#, but I have never tried it. Something to look into. If not then just create a native DLL with C/C++ that implements the LSP then have it communicate with your app.
You have to insert your code in the TCP/IP stack, which, if I understand correctly, requires a windows driver.
C# cannot compile native windows drivers, so you'll need to use a library or DLL to implement at least part of your functionality. Look for solutions using C++.
-Adam

Categories