Pulling files from remote system using java Runtime.exec on mac - java

All along I have been pulling the remote files using the Runtime.exec() first by connecting the windows remote machine using "use net.." and then pulling the required files. Now I have a new mac machine and I am unable to connect to that windows remote using java code. I can access the server from finder window using below command:
smb://userName:password#ipAddress/pathToFileOnRemote
but when I run this command in java code using the Runtime.exec() method, I get an error stating No such file or directory.
Is there a different way to access the file on the windows remote from mac as compared to windows?

Related

Launching jar file on Azure virtual machine

I am developing a java server-like application (though it is not a server itself, more like a bot for social network) and I decided to use Azure virtual machine to deploy the app on. So I've chosen Ubuntu virtual machine. I successfully uploaded .jar file on server, connected to it with Bash shell for Windows and SSH (as described in manual for Azure). Then I am able to launch my file with java -jar server.jar and it works. But the problem is that when I close the shell on my home computer, the app shuts down on the server too. So my question is how to launch .jar file in the way where it won't exit once I close SSH session?
Run the command in the background with nohup:
nohup java -jar server.jar &

run a jarfile in a different machine from an sqlserver/issue a terminal command from an sqlserver to another windows machine

I have a series of stored procedures(say, SP1, SP2, SP3) consecutively running on an sqlserver(say, serverA).
After SP3 finishes execution, I want to run a jar file in some machine (say, computerA). Is there a way for me to trigger the run of my jar file in computerA after SP3 finishes executing in serverA?
Note: I can only run my jar file in computerA because my jar file actually retrieves data from Bloomberg API. So, this jar file needs to run in a machine that has Bloomberg terminal on it. Only computerA has a Bloomberg terminal.
I think another way of saying this is how to issue a terminal command from an sqlserver to another windows machine. Because I can just issue the following command to computerA but I really don't know how to make that possible.
java -jar D:\Runnables\myJavaApp.jar

java program to Connect remote machine and execute batch file through WinRm

1)I partially connected to remote machine and use WinRm through Java to execute .bat file using xebialabs.overthere jars, which got rejected due to licence issue.
2) I even tried to connect remote machine and run batch file through PSExec (without using WinRm), but due to constraints of installing PSExec to our Master machine, this solution was scrapped.
Please help me if there is any way to get this done.
Thanks in Advance

Deploy java program on Linux

A web application has been developed in C# which hits my Java code through a restful web service which returns a JSON response.This process was working on a local machine with tomcat server. Now my Java application needs to be hosted on an external server in Linux environment.
Using putty, I logged into the particular hostname and as a root admin.
I have installed Java JDK 1.7, Apache tomcat server 7, my Java application as a war file is placed in the webapps folder. I can start the tomcat server too.
My question is:
How do I hit my application from windows. Is it http://x.y.z.k:8080//MYAPPNAME(war file name)/?
How do i check the java logs in the linux env?
Also I have a set of files that I read from my windows folders as in C://uploads//file.txt or C:\DeveloperTool\Pluggins\
I replaced them with the linux structure in my java code. as /home/opt/file.txt
Will this work?
How do I hit my application from windows. Is it
http://x.y.z.k:8080//MYAPPNAME(war file name)/?
If 8080 is the port Tomcat is configured to listen on (I think by default, it is), then that is correct. Bare in mind the web app name is case sensitive. You can configure this setting in $TOMCAT_HOME/conf/server.xml
How do i check the java logs in the linux env?
Since you're using a remote shell over SSH, you will want to use either tail or less to monitor logs in real time. The log files are stored in $TOMCAT_HOME/logs.
Try
$ less +F /path/to/tomcat/logs/catalina.out
catalina.out is the main file when running Tomcat on *nix systems.
Also I have a set of files that I read from my windows folders as in
C://uploads//file.txt or C:\DeveloperTool\Pluggins\
I replaced them with the linux structure in my java code. as
/home/opt/file.txt Will this work?
As Lutz Horn mentioned in the comments, try it. In theory, that should work fine as long as the permissions are setup properly.

Using RCP or FTP to copy files from a remote unix machine onto a local windows machine

I'm trying to write a piece of code that uses a ProcessBuilder to transfer a file on a remote UNIX machine onto the local Windows machine. On a brief bit of research I've found that either RCP or FTP should be a suitable thing to use.
Having done some research on the RCP command, I found instructions for copying files from a UNIX to windows machine, but they don't seem to work. The command I was told to use was:
rcp -r unixhost.user:/example/directory C:\Directory
However using this told me that C: was not a host. I tried it with the IP address, localhost, the alias of the windows pc in the hosts file but none of these worked, it either said permission denied or it could not connect to the host. Having looked up ftp it seems that would be another viable option. I'm not sure if I can execute a command using ProcessBuilder to successfully achieve this via FTP.
Would rcp or ftp be more suitable for this task? And how would I go about using them?
EDIT : To clarify, the script/batch file will be running on the Windows machine and pulling the files from the UNIX machine to windows.
It may be possible to escape the colon in the destination part. Have you tried quoting the destination?
rcp -r unixhost.user:/example/directory "C:\Directory"
It's been a while since I've done any command-line stuff on windows, but I remember the backslash character always being problematic. You may need to use forward slashes in the destination, since the rcp command is consuming the command line. You may also be able to use the backslash as an escape character, so you might try the following:
rcp -r unixhost.user:/example/directory C\:/Directory
If that won't work, you can explicitly set the current drive letter before calling the rcp command. If you're using a batch file, try the following two lines:
c:
rcp -r unixhost.user:/example/directory \Directory

Categories

Resources