I was wondering if it was possible to call a unix command directly from a Java program during run-time. This command could very very basic e.g. "ps -ef" returned as a string, all I need is a starting place so if anyone has any suggestion or examples I would be very grateful (2 Replies)
Hi - I am totally new to UNIX so please bear with me...
I run a java program on Win NT server to do file ftp to UNIX server.
I log in, cd, create ftp file on UNIX and quit from my java progam - all works well.
Now I want to execute a script on UNIX.
At the UNIX 'console'/'shell' (!?) you... (1 Reply)
hi everybody,
i have a small unix script and i want to use it with java, so how can i executte unix command with java (if it is possible): in fact i want to use some values returned by this script with java swings.
is it possible (of course everything is possible) but how can i do? thank you in... (4 Replies)
I need to pass an empty space in the command ="java ......... "
as one of the arguments where java calls some java command....
(It accepts it in windows as " ")
Thanks in advance
SD (2 Replies)
I have a java classpath running inside of a unix shell script. During my testing it will error with lines that show an example like this below.
java.io.FileNotFoundException error
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:129),
... (2 Replies)
Hi all,
I tried to execute the command by 2 ways :
1) Java Runtime class exec method - but the problem there is that it only can execute scripts without arguments(I need with args)
2) the Jtux classs Uprocess- the problem it is not supported by windows and my eclips platform is on... (0 Replies)
Hi,
when i compile my java code in UNIX using javac, the class file is getting created. But when i try to run the code using java - classpath command, i get the following error.
----------------------------------------
/u/up11/sample/request:>java -classpath /u/up11/sample/request... (0 Replies)
Hi All,
I have been struggling for a week trying to run a unix command from my java program.
the unix command is = ssh dmdev3@tsapid01-zt3d01 ':> /t3/envs/dmdev3/test/file_list.txt'
when i try to run this command directly on my unix console, it works perfectly.
but when i try it form my... (0 Replies)
Guys,
i need to check whether java file can be executed in my current unix system or not.
Can anyone please help me to get the correct command to check this.
My Unix system is HP-UX.
Thanks, (1 Reply)
Team,
I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list.
How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies
LEARN ABOUT DEBIAN
trycatch
TryCatch(3pm) User Contributed Perl Documentation TryCatch(3pm)NAME
TryCatch - first class try catch semantics for Perl, without source filters.
DESCRIPTION
This module aims to provide a nicer syntax and method to catch errors in Perl, similar to what is found in other languages (such as Java,
Python or C++). The standard method of using "eval {}; if ($@) {}" is often prone to subtle bugs, primarily that its far too easy to stomp
on the error in error handlers. And also eval/if isn't the nicest idiom.
SYNOPSIS
use TryCatch;
sub foo {
my ($self) = @_;
try {
die Some::Class->new(code => 404 ) if $self->not_found;
return "return value from foo";
}
catch (Some::Class $e where { $_->code > 100 } ) {
}
}
SYNTAX
This module aims to give first class exception handling to perl via 'try' and 'catch' keywords. The basic syntax this module provides is
"try { # block }" followed by zero or more catch blocks. Each catch block has an optional type constraint on it the resembles Perl6's
method signatures.
Also worth noting is that the error variable ($@) is localised to the try/catch blocks and will not leak outside the scope, or stomp on a
previous value of $@.
The simplest case of a catch block is just
catch { ... }
where upon the error is available in the standard $@ variable and no type checking is performed. The exception can instead be accessed via
a named lexical variable by providing a simple signature to the catch block as follows:
catch ($err) { ... }
Type checking of the exception can be performed by specifing a type constraint or where clauses in the signature as follows:
catch (TypeFoo $e) { ... }
catch (Dict[code => Int, message => Str] $err) { ... }
As shown in the above example, complex Moose types can be used, including MooseX::Types style of type constraints
In addition to type checking via Moose type constraints, you can also use where clauses to only match a certain sub-condition on an error.
For example, assuming that "HTTPError" is a suitably defined TC:
catch (HTTPError $e where { $_->code >= 400 && $_->code <= 499 } ) {
return "4XX error";
}
catch (HTTPError $e) {
return "other http code";
}
would return "4XX error" in the case of a 404 error, and "other http code" in the case of a 302.
In the case where multiple catch blocks are present, the first one that matches the type constraints (if any) will executed.
BENEFITS
return. You can put a return in a try block, and it would do the right thing - namely return a value from the subroutine you are in,
instead of just from the eval block.
Type Checking. This is nothing you couldn't do manually yourself, it does it for you using Moose type constraints.
TODO
o Decide on "finally" semantics w.r.t return values.
o Write some more documentation
o Split out the dependancy on Moose
SEE ALSO
MooseX::Types, Moose::Util::TypeConstraints, Parse::Method::Signatures.
AUTHOR
Ash Berlin <ash@cpan.org>
THANKS
Thanks to Matt S Trout and Florian Ragwitz for work on Devel::Declare and various B::Hooks modules
Vincent Pit for Scope::Upper that makes the return from block possible.
Zefram for providing support and XS guidance.
Xavier Bergade for the impetus to finally fix this module in 5.12.
LICENSE
Licensed under the same terms as Perl itself.
perl v5.14.2 2010-10-13 TryCatch(3pm)