I have two VPS on a farm and I whant to connect them with sshfs, to share some directories on a java application.
Source Destination
-------------------------------------------
VPS1:/app/path/data --> VPS2:/app/path/data
VPS 2 read and write in the sshfs mount and via shell scripts this does work regularly and very fast, because of the gigabit ethernet connection.
When my application starts to write files on VPS 2, in a non-predictable way fails to write files.
I tried to unmount location and write files locally and it works fine, without exception.
There are some strange incopatibilities between java.io.FileWriter and fuse? Or I simply miss something on mounting fs?
I tried this mount options:
sshfs user#VPS1_IP:/app/path/data /app/path/data
-o rw,allow_other,uid=${uid},gid=${gid}
An appending also:
reconnect,cache=no
The only non-standard thing I do with java is to write file, than rename it, to make an atomic operation, but when it fails nothing is written or renamed..
Any help is appreciated!
Thanks a lot, Davide
Related
Hello dear Stack community,
I am looking for solution for my test execution. I am using Java & Selenium & TestNG tests kept on AzureDevOps.
Each execution needs to load input data from file stored in external source - where client have an access and can easily drag-drop files.
By now files are stored on my companys Share Drive. It works all fine when I run tests from local machine, but when using pipeline, I get FileNotFoundException in line where file is loaded.
Does anyone have an idea why does it happen and how can it be overcome?
Of course if there is any other solution, I would love to hear about it.
It works all fine when I run tests from local machine, but when using pipeline, I get FileNotFoundException in line where file is loaded.
If you use Microsoft-hosted agents to access to files, which are stored on company's Share Drive, you should check whether there is correct connection. If your organization is secured with a firewall or proxy server, you need to add certain IP addresses and domain URLs to the allowlist. See: Allowed address lists and network connections for details.
Also you could use self-hosted agents to access to this shared files so it will communicate with company's Share Drive via your internal network.
How to update an MDB file from other machines remotely over the HTTP?
I have 2 machines that are connected by the internet, on the first, I have an MDB file and on the other, I have a java web application, I want to send an SQL query from the java web application to update the MDB file on the other machine over the HTTP.
I tried to use FTP, but it is transferring the whole file b
A file such as word, or power-point or Access?
Well, a horse is a horse is a horse.
A file is a file is a file.
You don't connect to a word file to update it. You don't connect to a Excel file, or a power-point file. And you don't connect to a Access file. You OPEN a file, and THEN modify it. You can't open nor modify files over FTP, nor can you modify them over HTTP either. And you can't even do that with a plane jane text file. These are files - you have to open them to modify them. Or pull a whole copy to one side. Update that file, and then send it back.
So, you don't want to confuse the concept of a simple file, or file based system like say a text file, excel file, or Access file. These are NOT servers or say a service that you connect to. You never open a MySQL file - you connect to a server + service via tc/ip (a socket conneciton) and then send commands back and forth. You NEVER open or touch that MySQL data file. The server updates that file - not you, and not your code.
So, Access is not a server based, or socket connection based service. It is a file based system - not un-like a text file. You don't connect to a text file, you HAVE to open that file - modify it and then save it. You can't do that over http. In fact you can't even do that with FTP either. You can pull the whole file, modify and then send it back to where you got that file from.
Now, you could however setup + create some web service calls or entry points on the one site. You could send that web site some commands, and then code behind on that web site can open up that text file, word file, or in this case the Access file and make changes . But once again, just like MYSQL or say the web server? You not opening the remote file direct - are you? You are (and can) thus setup some code or web methods (even REST ones) that accept commands, and those (even sql update commands) could then be run by that remote server/service and thus update the file on that target system. In the case of Access data files?
If you look VERY close, even a ODBC connection string ALWAYS ALWAYS resolves to a valid windows path name (and a full legal qualified windows path name at that).
so, while there is a ODBC driver, the software driver still in fact uses a standard windows OS file open command against that plane jane file sitting in the hard disk. So to update that Access file, you need the driver - since it knows how to open that file, and how to update the delicate data file structures inside. So, even via ODBC? Well, it not a socket connection and you not connecting to a server on the other end - but in fact opening a simple windows file. In fact this means that you not only require DIRECT file rights to that access data file - but you actually need the windows file system!
However, sqLite is the SAME thing. There are thus some jdbc drivers. This JDBC concept is VERY similar to ODBC, but is for web based systems. You install a library on one end (where sqlite resides), and then that web service can take your sql commands (updates or query pulls), and thus the web site code now opens that local file, executes sql against it, or does a query pull , and then returns the results of your query - and the web query calls are done via that web service (rest calls) on that server. So, you can in theory shuffle commands between two web servers - and there are some types of "drivers" such as jDBC standards that in theory do wind up giving you a similar experience to ODBC.
Background: I am trying to run some Java code on a few target machines (to check registry values using JNA) and I don't want to have to install Java on every machine I need to check. I thought that a possible solution was having the server running the Java app use a batch file that lives on the local server. This batch file would simply call a Java program and get the data I needed from the remote machines.
Question: I have a local batch file that I am executing using Java. This batch file will remote execute on target machines. The batch file calls/runs a Java program. Is it possible for that Java program to live on the main server or does it need to live on the target machines as well?
if understood right, you could just say to the batch file to print a report of registry info that you are searching, then use java to directly reach that report, and then you could "analyze" that code in your "server"
with this you don't need to have java installed on local machine, and you don't need to launch "application" but simply: a script.
I want to open a file on remote windows machine from my local windows machine. The file should be visible on remote machine only.
My problem is, I should open a bat file on remote pc which creates access to do something like opening browser etc.
I did using PSExec to run the bat file remotely. Everything looked good, but when i try to open the browser on remote pc, it does not open browser but shows browser processes in task manager.
When I go and open that bat file manually on remote machine everything works fine. Browser opens and my work is done.
But I want to do that from my local machine especially from the command line. So that I can use this commands in Java.
Please help. If question is not clear please ask for more info.
Try using the -i option with psexec or specifying a session ie. -i 1
From the psexec manual.
'-i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session.'
example:
C:\SysinternalsSuite\psexec.exe \remotecomputer -u DOMAIN\administrator -p adminpass -i 1 "\remotecomputer\c$\Program Files (x86)\Google\Chrome\Application\chrome.exe" http://tinyurl.com/6fbgntx
I'd suggest you to use WMI - It management instrumentation. It allows running process on remote machine (obviously if you have enough permissions).
You can either access WMI from Java using one of popular interoparability libraries (JaWin, JInterop, JIntegra) or write JScript or VBScript and execute it from java.
JaWin and Jinterop are open-source. JIntegra is not.
JaWin requires windows OS on client machine. JIntegra and JInterop can be executed from other OS.
I used all 2 suggested methods and all 3 libraries. Probably now I prefer JInterop.
We have a web application hosted on this webLogic server on a UNIX machine. Its primarily a JSP/Servlet based app. Whenever we do a modification/enhancemment to any one of those JSps or servlets, I precompile them on my local and deploy them on the UNIX system. For example, if there is a file called GetIdServlet.class, we usually rename the existing file to say GetIdServlet.class1 and then put in the new file as GetIdServlet.class. This is just to be able to revert back to the original file in case they are needed. However, I notice very strange behaviour. The application loses some functionality whenever we stop and start the server. The functionality may be back on the next or a few restarts after that. For example, a submit button that is supposed to direct it to the next page just stops working. It may start working after a few restart.
However on my local(Eclipse + webLogic) there is absolutely no issue. Everything works fine. Any ideas on what's going wrong?
You are using Unix Environment and i assume that the local desk setup used is windows OS or MAC. thus, when you copy the class files you are using some tool like WinSCP.
in case so, then please set the copy settings of such tool to use binary method of copying the files.
Example in WinSCP. go to Options->Preferences->Select Transfer in the Side Menu->under the Transfer Mode section, Select Binary option as the Transfer Mode. This will ensure that the binary replica is created on the Unix environment and that no data is lost in the transfer.