I'm trying to automate creating torrents/starting downloads/limiting Bandwidth... etc using Vuze.
So far I've written a shell script to send Vuze and the torrent to all the clients. However when it comes to creating torrents, after executing this command : java -jar Azureus2-XXX.jar --ui=console or java -jar Azureus2-XXX.jar --ui=console &, the console looks like this and no command after that works unless I quit the Java program.
Any help would be much appreciated. Thanks!
Related
I am doing something about getting execution logs form a java program. But I just achieve this when it's a jar file using command like java -javaagent:agent1.jar -jar MyProgram.jar . But if there is a software which don't need using java -jar to open , how can I use my agent1.jar to get its execution data ? For example, I made a game by java ,and I open it by opening the file MyGame.exe ,which mean that I can't use javaagent:agent.jar to instrument and get logs.
Are there any ways to solve this problem or any other tools can give me a reference?
I have a problem running the exec command from within a php script.
here's the detailed scenario:
I have an executable my_exe which runs from command line. This executable uses an environment variable, so I prepend the command with MY_VARIABLE='value' (works fine).
I use the exec command to run this executable from a Php script. ex: exec("MY_VARIABLE='value' my_exe"); (works fine too, tested in a browser)
The problem is in this part. When I call the php script from a Java program using HttpUrlConnection, I have two cases: if I run the Java program from outside the server (using public IP address) I get the good results, but when I run it from the server (using local IP, form command line ex. "java -jar /path/to/my/jar"), the Php works but the exec doesn't seem to be working properly. The environment variable is not being set in this case, so the executable runs but without the right values, so I get no results.
Any help is appreciated. I'm really stuck here. My guess is that there is a problem with Php or Java permissions, but I can't figure it out.
Strange command exec("MY_VARIABLE='value' my_exe");... it will work only on linux machine and will not on windows.
As a first step, try to rewrite you php code like this:
putenv("MY_VARIABLE=value");
exec("my_exe");
and see what happen.
I'm trying to code a shell script to start/stop torrents using vuze's console UI through SSH:
https://wiki.vuze.com/w/Console_UI
I've downloaded vuze and everything works fine until I type this command:
java -jar Azureus2.jar --ui=console
After that, no command in my script works unless I quit that console.
Any solutions please? And if it's not feasible using shell scripts, any suggestions please?
Thanks.
Basically, the moment you run that command, your java program runs 'in the foreground', which means the rest of your script stops executing until your program exits.
If you want to keep on running the rest of your script while your java program executes you have to run your program in the background. One way to do that is as #Alp suggests:
java -jar Azureus2.jar --ui=console &
Setup:
I am working on a Java project which invokes some Perl scripts.
Problem:
If I run the Perl script from terminal, it works fine. But when I invoke the same Perl script with same arguments from Java code, it fails. It is an extremely strange and annoying bug.
I am able to debug Perl in Eclipse using EPIC plugin. And of course, I can debug Java code. It would be helpful to debug Java and Perl code in the same debug session in Eclipse, so that I can see whats different happening when the script is invoked via Java code.
Not sure if this is even possible, but if anyone has any idea, please share.
Thanks.
Perl has some remote debugging capabilities, so you can get what you need, I think. I don't use EPIC, so I don't know if you'll be able to do it all within Eclipse.
Set the environment variable named PERLDB_OPTS to have the value RemotePort=<host>:<port>. Then, start Perl with the -d flag. Instead of the debugger trying to interact with standard IO on the invoking terminal, it will attempt to connection to host:port.
Here's a Unix-y example. I've got a Perl script hello.pm and two terminal windows open.
First terminal
$ nc -l 12345
That's started NetCat as a dumb server listening on port 12345. If you don't have a server listening before Perl starts, it won't work.
Second terminal
$ export PERLDB_OPTS=RemotePort=localhost:12345 # set the env variable
$ perl -d hello.pm
Now the script is running. Back on the first terminal, I see
First terminal
main::(hello.pm:1): print "hello\n";
DB<1>
I'm in the Perl debugger and ready to go!
I know that at least the Komodo IDE has support for remote debugging, and there's a Perl Monks post on doing it with Emacs, so you can get something more than the command line even if it's not Eclipse. Good bug hunting!
If I run the Perl script from terminal, it works fine. But when I invoke the same Perl script with same arguments from Java code, it fails.
I suggest that you check that you are running the same version of Perl in the two "contexts"; i.e. when the Perl app is run from the command line and from Java.
If that's not the problem, check the environment variables.
The other approach to solving this problem would be to focus on why the program is going wrong, not on how / why the contexts are different. Look at the evidence that you have, and look at ways to gather more evidence ...
The potential problem with trying to do this using a Perl a debugger (in an IDE or stand-alone) is that you are actually running Perl in third "context" which might be different from either or both of the existing ones.
Using a debugger may work ... or it may leave you even more confused.
I have a program that uses external libraries and code I've written in Java. However, I want to make it accessible via the web.
If I had full control over the webserver I was running it on, I would probably use Tomcat or JBoss, but I don't have such privileges at my school.
The servers I do have access to have Apache HTTP server with all the normal Linux goodies installed (think: Perl, PHP, etc.)
How would I write a Perl script that runs this Java program?
I've tried the basics such as "system java MyProgram" and "exec java MyProgram", but they don't seem to work.
I'd appreciate any help or insight on this. Thank you!
Process process;
try
{
process = Runtime.getRuntime().exec("cmd / c start c:\\Perl\\bin\\file.pl");
try to run like this as per your program.
When you run a CGI script, the environment is very limited, and this includes the PATH. Is it possible that your CGI script can't find the java command? Or maybe Perl simply is refusing to run the system command when in CGI mode (aka taint mode). See perldoc perlsec for more information.
Basically, you need to set PATH and then try running your system command with your java command.
Try this:
system('/full/path/to/java -cp full_class_path my.class.Name');