How to use FSharp.Management WMI Provider with remote machine - f#

I've modified the example script from the FSharp management project to connect to a remote host rather than localhost:
System.IO.Directory.SetCurrentDirectory (__SOURCE_DIRECTORY__)
#r #"System.Management.dll"
#r #"..\Packages\FSharp.Management.0.3.1\lib\net40\FSharp.Management.dll"
#r #"..\Packages\FSharp.Management.0.3.1\lib\net40\FSharp.Management.WMI.dll"
open FSharp.Management
type Remote = WmiProvider<"remotehost#username:password">
let data = Remote.GetDataContext()
Unfortunately I get an error the GetDataContext is not defined on Remote. But if I change the WmiProvider to be WmiProvider<"localhost"> the it works as expected.
I wasn't sure if the login is correct but if I change the username or password to something I know to be incorrect the the WmiProvider line returns an RPC error so I am sure it is logging in correctly.

There are actually two different times that the WmiProvider communicates with the system: Design Time and Run Time. In your sample code, you are connecting the WmiProvider to the remote machine at Design Time, meaning it will try to retrieve the WMI "Types" from the remote machine. You could try using localhost at Design Time, since you said that seems to work, then using the remote machine at Run Time.
An example of using the remote system only at Run Time would be like this:
open FSharp.Management
type WmiContext = WmiProvider<"localhost">
let wmiContext = WmiContext.GetDataContext("remoteMachine")

Related

Can Rails pass a shell command to the local machine?

I am trying to get rails to select document attachments, then kick off the email client with the documents attached.
I have it working on my development laptop. If I build a string with the appropriate parameters and pass that to system() then it kicks off the email client with the attachments..
The string looks something like
#email_content = "C:\Program Files (x86)\IBM\Lotus\Notes\notes.exe"
"Mailto:?Attach=C:\Users\cm\RubymineProjects\technical_library\public\images\1\8302_printed.pdf
The first part calls the notes exe and the second part starts and email with the attachments. That worked fine on my laptop.
However, when I moved it to the server, it isn't kicking off the email client. I believe that it is because the shell commands are trying to execute on the server, not on the client.
Is it possible to run a shell command on the client machine? I am trying to get this working with Windows first and then the Mac environmemnt. I tried changing the C:\ to the machine name. i.e. \chrislaptop\Program Files (x86)\IBM\Lotus\Notes\notes.exe. but that didn't work.
No, fortunately that is not possible.
Imagine what happens when a request to some random page on the internet could trigger shell scripts on your local computer...
Arbitrary code execution escaping the browser is too invasive-- your app should not have access to the client's machine.
However, some applications may support URIs that open specific applications outside the browser. You generally see this more on mobile devices, but Spotify for example supports links that look like: spotify:artist:5lsC3H1vh9YSRQckyGv0Up which asks the user whether it is ok to open the Spotify application.
https://news.spotify.com/us/2008/01/14/linking-to-spotify/

F# web service data provider with local wsdl file

I am trying to write F# client for our web services. The example here looks very good except it uses the server url in the code.
type TerraService = WsdlService<"http://msrmaps.com/TerraService2.asmx?WSDL">
This prevents me from reading service url from configuration file at run time, and make deployment from dev server to production server difficult.
I am wondering if there is any WSDL provider that works similar to Dbml Provider
I'm not sure I understand exactly what you're looking for, but note that the URL provided as a static parameter is used to generate types, but if desired a different URL can be provided at runtime by using a different overload of the Get...Soap method. This URL can come from wherever you want (e.g. you can read it from a config file if that's your scenario). E.g.:
type TerraService = WsdlService<"http://msrmaps.com/TerraService2.asmx?WSDL">
let terraClient = TerraService.GetTerraServiceSoap(EndpointAddress(myRuntimeUrl))
Nothing currently exists that does that but the code is open source so you could make a version of it that work's in the mode that you desire:1 2.

couchbase ios replication error

Im new to couchbase and have been struggeling with an error for hours.
I create a user_profile_<-insert guid here-> document and save it successfully to local mobile couchbase db
with the following test data:
{
"_id" = "user_profile_F6854F81-FE36-4D6B-BD69-DAEBF0E9D766";
"_rev" = "7-9012d2c1990b4c2ab4eb96cdf6c7dbdb";
birthday = Birthday;
gender = Male;
name = Ted;
uuid = 123456789;
}
I have set up replication to a remote couchbase server.
However, each time it tries to replicate I get the following error:
[error] [<0.102.0>] Error in replication
`bb788350a95e4580ddc768d760f89575+continuous`
(triggered by document `d15feb5b5838e5044cdd7b9d9b0009f8`):
{invalid_json,{{error,{1,"lexical error: invalid char in json text.\n"}},
<<"Not found.">>}}
I've been stuck at this problem for about 6 hours now.
Could someone please help here? :)
Thank you !
Update:
I downloaded the project at https://github.com/dthompson/couchbase-ios-example/
and when I run it I get the same error
I have had the same problem but I was trying to use the futon replication functionality. It turned out the problem was due to the way I was inputting the remote database address.
For example: The local database I wanted to replicate is called "cardata"; On my remote server (with the same user account like on my local) I created a database "cardata" whose address is http://your_remote_server_name:port/cardata.
When I used the above format for remote server it worked fine. The erroneous address I had used at first was in the format: http://your_remote_server_name:port/_utils/database.html?cardata.
Considering my experience as detailed above, you too could be inputting the address of your remote server wrongly. Check it to make sure you input it correctly.
NOTE: If your local installation is of a different version from that on you remote server, the difference is not the cause. I checked it, I had 1.2.0 on local and 1.0.1 on the remote server. So I upgraded the server to 1.2.0 and still I had the problem until I fixed the address as explained above. Good luck man.

Best way to get the TFS URL

I found number of sample of the TFS Api using the TFS Url to get the tfs server.
Is there a way to use the default server configured on the machine.
I don't want to put the URL in all the dll I write or in all the script.
You can also look at the list of locally known TFS service in the windows registry: How do I get a list of Team Foundation Server Servers available on my PC?
Obviously you need to get the machine name from somewhere I suggest if its not found in config or some other mechanism you try some of these bits of code to get the machine name and try to connect to the local machine on the default port if not specified elsewhere
string name = Environment.MachineName;
string name = System.Net.Dns.GetHostName();
string name = System.Windows.Forms.SystemInformation.ComputerName;
string name = System.Environment.GetEnvironmentVariable(“COMPUTERNAME”);

IPC Remoting problem

We are receiving the following error using IPC.
"Failed to connect to an IPC Port: The system cannot find the file specified."
The issue is happening on a Windows 2003 server.
Of course it only happens in production. We are unable to reproduce this in our development environment.
The Windows service that is attempting to use IPC is running as Local System.
Is there some sort of permission that needs to be changed?
We were attempting to access the channel before it was spun up. So we would receive the 'not found' error. Wrapping the access code in some 'is it really ready' code fixed the problem.
For me DTA was working fine. But Suddenly I started getting this same error.
For me the fix was this:
-> Go To Task Manager
-> Go To Processes Tab
-> Find and kill the DTA process. For me this process is named as 'DTASHELL.exe'
Now try to launch DTA. It should work now :-)
We had this problem in production code. It was failing on a small percentage of user's systems.
The error turns out to be in the microsoft code that we were using. It generates the IPC channel using the username.
ipc://APP_USER_000:SingeInstanceIPCChannel/SingleInstanceApplicationService
with certain characters in the username, this generates an invalid channel URL, so the receiving app fails to create the channel in the first place.
our fix is to use a hash of the username, rather than the first characters in the username.
(we were using the code here: http://blogs.microsoft.co.il/blogs/arik/archive/2010/05/28/wpf-single-instance-application.aspx )
Please post the code you use to initialize the server channel and publish the object, and the client code with the uri you use when you try to access the remote object.
A common pitfall is when you initialize the channel with a dictionary, and set the name of the channel using
dic["name"] = "channelName";
//used for retrieving the channel - ChannelServices.GetChannel("channelName");
instead of
dic["portName"] = "channelName";
//used as the identifier for the named pipe -
//The client should get the object from the uri : ipc://channelName/objectName

Resources