03-29-2008
Argh, right, I missed that even though I was specifically looking for it! Good catch.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
#!/bin/bash
for file in $HOME/*;
do
if ; then
rm -i $file > /dev/null
echo "$?"
echo "$file has been deleted"
fi
done
Been trying to learn shell scripting for a week or so now, when i run the script it doesnt display an error message, seems like it runs fine, however it doesnt delete... (10 Replies)
Discussion started by: stride6
10 Replies
2. Shell Programming and Scripting
What is wrong in my IF loop
if
then
echo " The request is authenticated "
fi
The error im getting is
$ ./routing.sh server enables
**********************************************************************
Preparing to service the request for Device server in Question... (9 Replies)
Discussion started by: raghunsi
9 Replies
3. Shell Programming and Scripting
Hi there, i've written a script to extract a portion of a MySQL database table and convert it to CSV and then to import it back as CSV to MySQL. Initially it worked without the while loop but after adding the while loop statement, i am getting the following error:
./export-csv-coordinates.sh:... (4 Replies)
Discussion started by: edge80
4 Replies
4. Shell Programming and Scripting
Hi all,
I have been given a task to search for strings in a file that is encoded. I need to display the file name only when all the 3 strings which i provide are present in the file name.
i first try to get a list of files according from the directory according to the value passed in argument... (0 Replies)
Discussion started by: amit1_x
0 Replies
5. Shell Programming and Scripting
hello everybody,
here's my code
mkf ()
{
INDEX=0;
while ; do
touch "file$1.f";
INDEX=$INDEX+1;
done
}
when I type
mkf 10
the loop seems to act infinite
and only the last file of the loop is created, in the example below, there just is file10.f in... (11 Replies)
Discussion started by: Oddant
11 Replies
6. UNIX for Dummies Questions & Answers
Hello guys,
This truly is a newbie question. I'm trying to make a loop to execute simultaneous commands indefinitely while using variable. Here is how my mess looks like (this is just an example):
#!/bin/bash
IP=`shuf -n 1 IP.txt` # I figured this would be easier to select random lines... (4 Replies)
Discussion started by: bobylapointe
4 Replies
7. Shell Programming and Scripting
Hi ! all I am just trying to check range in my datafile
pls tell me why its resulting wrong
admin@IEEE:~/Desktop$ cat test.txt
0 28.4
5 28.4
10 28.4
15 28.5
20 28.5
25 28.6
30 28.6
35 28.7
40 28.7
45 28.7
50 28.8
55 28.8
60 28.8
65 28.1... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies
8. Shell Programming and Scripting
Here's my code:
awk -F '' 'NR==FNR {
if (/time/ && $5>10)
A=$2" "$3":"$4":"($5-01)
else if (/time/ && $5<01)
A=$2" "$3":"$4-01":"(59-$5)
else if (/time/ && $5<=10)
A=$2" "$3":"$4":0"($5-01)
else if (/close/) {
B=0
n1=n2;
... (2 Replies)
Discussion started by: klane
2 Replies
9. Shell Programming and Scripting
Hello everyone,
I need a little help. I wrote a cshell script to change the format of a file but it is not working.
input file is like that:
2014 3 20 15 0 5.270 40.7739 27.6471 20.232 0.6 0 0 0 1
Site6 4.081 1.00 P
Site6 7.585 1.00 S
Site1 4.441 1.00 P... (9 Replies)
Discussion started by: miriammiriam
9 Replies
10. Shell Programming and Scripting
function get_tablespace()
{
## Get the current size of the tablespace
size=`su -l oracle -c 'db-control report' |egrep "DATA_TBS" | awk '{print $5}'|tr -d '%'`
## Loop through until the size is 82 or less
count=0
while &&
do
... (2 Replies)
Discussion started by: bille
2 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)