Can I copy a file from one server to another? - coldfusion

I am using ColdFusion 8.
I am trying to write a file on a networked path Windows.
// THIS WORKS
CatalogDirectory = getDirectoryFromPath("E:\INETPUB\WWWROOT\AVCATALOGS\AVCAT\");
// THIS DOES NOT WORK
CatalogDirectory = getDirectoryFromPath("\\ourserver\e$\InetPub\wwwroot\AVCATALOGS\");
I can't find any good documentation on what you CAN'T do.
// TOO VAGUE
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_e-g_36.html
Is there a way to write copy a file from one server to another server on networked drives?

you must be running ColdFusion as a network user and that user must have permission to access the server you are connecting to.

Related

Java EE Webservice - How to save a json without a database

I have a REST service with a simple get and post method in Java EE. The post method saves the recieved json in a file using Gson and FileWriter. On my local system the file is saved in C:\Users...\Documents\Glassfish Domains\Domain\config. The Get method reads this file and gives out the json.
When I test this on my local system using Postman, everything works fine, but when I deploy the project on a Ubuntu Server vm with Glassfish installed, I am able to connect but I get a http 500 Internal Server Error Code. I managed to find out, that the errors are thrown, when the FileReader/FileWriter tries to do stuff. I suppose that it is restricted to access this directory on a real glassfish instance.
So my question is, if there is a file path where I am allowed to write a file and read it afterwards. This file has to stay there (at least during the applicationr runs) and has to be the same for every request (A scheduler writes some stuff into the file every 24 hours). If anyone has a simple alternative how to save the json in Java EE without an extra database instance, that would be helpful, too :)
If you have access to the server then you can create a directory using the glassfish server user. Configure this path in some property file in your application and then use this property for reading and writing the file. This way you can configure different directory paths in different environments.

Connecting SAS and FTP server(or network drive)

I'am completly new to SAS(and all these techincal things), but i need connect a network drive (or FTP?) to SAS, so i can copy or send files to it. I guess, it should look like another server at a workspace or something. I only know the address of it(maybe it will give you some clue):
\\10.48.42.166\exportsexternal1\oaDiez0Naf
The problem is even in that i don't know how to google it correctly - all link's are mainly about FILENAME in FTP

How should a system get data from a remote third party data source?

A vendor's remote system has data that one of our internal systems needs daily. Our system currently receives the data daily by the vendor's system pushing a CSV file via SFTP. The data is < 1KB in size.
We are considering using a pull via SFTP instead. The file "should" always be ready no later than a defined time (5 ET). So, one problem with this approach could be that our system may have to do some polling to eventually get the file.
How should a system get data from a remote third party data source? The vendor also provides a web service and subscription feed service. They will also consider other ideas for us to acquire the data.
Assuming your system is unix-like, and the other side has an open SSH server, I would add the public key of the user that your application runs under to the authorized_keys file in the remote side. After this, your application would be able to poll for the existence of an updated file by running
ssh username_at_remote_end#ip_address_of_remote stat -C %Z path_to_file
Which will output the seconds after the unix Epoch of the last change to the file (if found) or error (non-zero exit code) if file not found.
To actually retrieve the file (after checking that the time-stamp is within the last 24 hours), I would use
t=$(mktemp -d) && scp username_at_remote_end#ip_address_of_remote:path_to_file $t && echo $t
Which will copy it to a temporary directory under /tmp, readable only by the user that your application is running under, and will return the name of that folder.
All programming languages support running commands locally (in C, using system(); in Java, using a Process; ...). To keep things simple, each command would be added to a script file (say poll.sh and retrieve.sh). If the remote end changes, you only have to update & test the scripts. There are direct interfaces to openssh, but it is probably simpler to outsource all of that work to bash via scripts as seen above.
IF you have similar requirements for more that one case, you can consider using integration server (middleware) to implement this. There you can design a trigger which will invoke that particular pull after 5 ET.
If this is required for only one case, then ask your provider for webservice option. Where you can call his webservice after 5ET once a day by sending a soap request for data and he will return a soap response rather than csv. You can implement it very easily in your system. It will be more secured and efficient. You will have more control on data, transport and security.

Remotely control application settings

I have a solution that acts as client service and does some background work. This application requires some settings (that are read from an xml file) to be done at installation time and which are periodically revised. For convenience (as this service is installed on multiple machines) I wanted to control these settings remotely from a central server application. This works fine if the server and client are inside the LAN but I would like to control these settings even if the client is outside the network or the server is behind a firewall. What could be the solutions to do this?
Clearly, the solution depends on exactly what you want to achieve. But if I understand it right, the reason you have "problems" with a firewall is that you simply access the file that contains the XML over the network using standard network file access. Which is typically (for good reason) blocked by the firewall.
So, the solution then would be to use a standard protocol and a "non-standard service". For example, if the machine is allowed incomming HTTP requests, you could use HTTP-based post messages to update the XML content, either send the entire file as a file upload, or make up your own remote access protocol. If HTTP is not allowed, then you have to look at what other "holes" there are in the firewall, and do something similar with another of the "holes".
The other, less obscure solution, is of course to simply use a remote-desktop or secure shell connection to remotely access the machine. Of course, again, assuming this sort of connection is allowed.
There is no magical "bypass firewall" solution - you have to work within the rules of the firewall in some way.

How to start a process on a remote machine in C++ under Windows

I'm using Dev-C++ under Windows. My question is how can i start a process on a remote machine? I know that PsExec can do that, but if it's possible, i want to avoid to use it.
If someone can give some example code, i would appreciate it :)
Thanks in advance!
kampi
If this was easy, hackers would be starting up malware on all machines exposed to the internet.
PSExec uses the Services Control Manager over a LAN to start a service EXE from 'here', i.e. the machine where you run it. It requires a lot of security privileges - e.g. admin rights.
If you don't want to do this, you can look into SSH (there are open source examples) or Remote Command Prompt (in Windows Resource Kit).
You can use WMI... (C# example so you'll have to find the equivalent C++)
ConnectionOptions connectOptions = new ConnectionOptions();
connectOptions.Username = "Administrator";
connectOptions.Password = "TopSecret";
ManagementScope scope = new ManagementScope(
#"\\" + machine + #"\root\cimv2",
connectOptions);
scope.Connect();
ManagementPath path = new ManagementPath(#"Win32_Process");
ManagementClass proc = new ManagementClass(scope, path, new ObjectGetOptions());
ManagementBaseObject args = proc.GetMethodParameters("Create");
args["CommandLine"] = "C:\\Windows\\notepad.exe";
proc.InvokeMethod("Create", args, null);
It would be best if you already have a service running on the remote machine which you can ask to run a program. Windows itself does not provide anything useful out of the box; it does ship with a remote shell service (which is usually deactivated or not even installed).
IIUC, what psexec does is this:
copy a the binary onto the remote machine, using an administrative share
install the binary remotely as a service, using remote registry operations
start the service remotely, using the service control manager API.
If you don't want to use psexec, you could still do the same. Notice that you need quite some privileges to do so.
The simple answer is that you can't. All you can do is send a message to the remote machine asking it to start the process for you. PsExec runs on the remote machine listening for specific messages and starting processes in response to them.
You can either use an existing protocol, like PsExec, or create your own. Creating your own requires that you can install a service on the remote machine. If the remote machine is not under your control then this isn't possible. If you do design your own system you must be careful when designing the protocol as you don't want to inadvertently open a security hole in your system.