Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Upload a file to unix and invoke a java method

 
Cindy Jones
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to upload a file to a file on a unix machine and process that file using some additional parameters.
One way of doing this is to have a web application using which I can upload the file to the unix system and which also accepts the additional parameters.
However my unix machine does not have any webservers and we are not planning on having one unless absolutely necessary.
The alternative is to upload the file using WinSCP, and run the java code that processes the file from the console.
Are there any other alternatives? I thought that running a Swing FileChooser might be the answer, but not anymore (1. FileChooser would let me choose files on the UNIX box and not on my local machine 2. To get Swing to work I have to have X11 installed)
Any suggestion would be appreciated!

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I'd use a web app. But how about using a simple FTP server and run a daemon on the machine that detects when new files have been uploaded and triggers the post-upload actions?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. At a previous job we did this with email. The clients would email files as attachments and the email server would store the messages in the file system. A daemon detected new messages, fetched the attachments, and processed them.

FTP would be cleaner, but these clients were very technically-challenged and getting them to use email was about as technical as they could get.
 
Cindy Jones
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with using the FTP server is that the users also need to pass some additional parameters.
Thanks for your suggestions - now I know I am not missing any obvious solutions and that the webserver route might be the way to go after all.
 
Paul Clapham
Sheriff
Pie
Posts: 20945
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We do that by first uploading the file to the FTP server, then using the FTP "RCMD" command to run the program which processes the file.

It takes a bit of configuration to get the path set up on the server, and so on. And you should be careful with security if your FTP server is exposed to the Internet (allowing anybody in the world to potentially execute arbitrary commands on your FTP server would be dangerous).
 
Cindy Jones
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am on the lookout for a solution that would appeal to "technology challenged" clients
Thanks for your your tips!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm, if the web app route doesn't pan out, perhaps the email solution, where the extra information could be sent in the body of the email, might serve?
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are some Java libraries for SSH which might work well if the Unix box runs OpenSSH, uploading the file with SCP or SFTP, then running the command through the shell. Have a look at JSch and Trilead.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic