2

My web page uploads a file. Currently it places that file in a directory which is polled by a cron job. If the file is there, a bash script acts on the file. I hate the fact that I am polling. The upload happens perhaps once a week, but the user wants to see results within minutes from their file, so I end up polling every 5 minutes.

So rather than polling, I'd like to evoke the script once the upload is complete. How can I get my web page to fire up the bash script. The web page is coded with JSP.

2
  • Just a note that you've got quite the entry point there - make sure you've done a thorough security audit here! Commented Jan 21, 2009 at 22:59
  • @LFSR, The upload page is authenticated and within our intranet. It is not an issue. Commented Jan 21, 2009 at 23:03

2 Answers 2

3

So long as you haven't got a SecurityManager set, you can use Runtime.exec to call an executable program. In particular you can run /bin/bash (or whatever path it is to your shell). Note the -c option for shells.

As LFSR points out, this is the sort of thing likely to be full of security flaws.

Sign up to request clarification or add additional context in comments.

1 Comment

java.lang.SecurityManager. Not very fashionable. Mostly used for applets and WebStart.
-2

Why don't you do this from your app? It won't be very hard to implement an FTP client in Java. Surely there are open/free libraries to accomplish this somewhere. I don't believe this script does anything that you can't do in Java. A message driven bean with the FTP code should be enough. Your server is not FTP? Well, installing FTP isn't that hard either.

1 Comment

The script does more than we are willing to write in Java. Not because Java can't, but one line in bash to do a rsync using a dsa/rsa link would take considerable effort to replicate in Java.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.