Sponsored Content
Full Discussion: Help with commands
Top Forums UNIX for Dummies Questions & Answers Help with commands Post 302696089 by Newer on Tuesday 4th of September 2012 09:25:44 AM
Old 09-04-2012
Help with commands

Hi again guys, today i bring to you new doubts, let me show the first example
Code:
#!/bin/bash
# ligass: lista archivos que son enlace simbólico o tienen enlaces hard
# simbólicos: en ls -l se busca que empiece con l
if [ ! -d $1 ]
then
  echo Error: ligas: $1 no es un directorio
  exit

Moderator's Comments:
Mod Comment code tags please

On the line of condition i can't figure out which is the function of $1, when, and for what i can use it.

other example.
Code:
TARGET=$1
DAYS=$2
SUBJECT=$3

Any one who has patience to explain to me?
Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

commands

hi, I'm completely new to FreeBds or unix in general, is there a really nice site to teach you the basic ommands to free BSD. I don't know what to do. =( (3 Replies)
Discussion started by: Special K
3 Replies

2. Shell Programming and Scripting

commands

anyone know the command to display the ten most common words, together with their number of occurences, in the manual entry for the ls command. It would be much useful (1 Reply)
Discussion started by: master_6ez
1 Replies

3. Programming

code that reads commands from the standard i/p and executes the commands

Hello all, i've written a small piece of code that will read commands from standard input and executes the commands. Its working fine and is execting the commands well. Accepting arguments too. e.g #mkdir <name of the directory> The problem is that its not letting me change the directory i.e... (4 Replies)
Discussion started by: Phrozen Smoke
4 Replies

4. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

5. AIX

HACMP: difference between 'cl' commands and 'cli' commands

Hi all, I'm new in this forum. I'm looking for the difference between the HACMP commands with the prefix "cl" and "cli". The first type are under /usr/es/sbin/cluster/sbin directory and the second are under /usr/es/sbin/cluster/cspoc directory. I know that the first are called HACMP for AIX... (0 Replies)
Discussion started by: peppix
0 Replies

6. UNIX for Dummies Questions & Answers

help with some commands

Hi! i'd like from someone to explain me 'what is what' from these parts of code if it's possible.i'd like to understand them and their usage: 1) sed '3d' filename 2) sort –t: +0 -1 /etc/passwd and also this: tr ‘’ ‘ ‘ < filename thank you! (11 Replies)
Discussion started by: strawhatluffy
11 Replies

7. UNIX for Dummies Questions & Answers

Need help with certain commands

I'm trying to figure out certain commands for these steps. If you wish to discuss with me in real time, PM me your AIM or MSN, thanks. Here are the steps. Edit the readcal_final file Delete all of the lines that comprise the colandar portion of the memo Without leaving vi, open a new... (0 Replies)
Discussion started by: vgmaster9
0 Replies

8. UNIX for Dummies Questions & Answers

Vi % commands

How can I find a list of shortcut commands I can execute within vi using the % indicator? For example, I can vi a file, press colon, and then type "%s/\r//g" to remove all instances of a carriage return. What else can be executed from the % prompt and what are the shortcut letters (I could type... (4 Replies)
Discussion started by: MaindotC
4 Replies

9. Shell Programming and Scripting

Ls commands

So I need a way to list all files that contain 4 letters. Also separately I need to find a way to list all files with l or n as the third letter of the name. I need to use the ls command and/or grep/egrep. Any help would be a appreciated. (2 Replies)
Discussion started by: muttfacejohnson
2 Replies

10. Homework & Coursework Questions

What are the commands for this ?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: If the user enters option 1, your program should display the list of entries in the current directory. For... (1 Reply)
Discussion started by: UniverseCloud
1 Replies
libapache2-mod-perl2-2.0.7::docs::api::APR::Error(3pm)	User Contributed Perl Documentation libapache2-mod-perl2-2.0.7::docs::api::APR::Error(3pm)

NAME
APR::Error - Perl API for APR/Apache/mod_perl exceptions Synopsis eval { $obj->mp_method() }; if ($@ && $ref $@ eq 'APR::Error' && $@ == $some_code) { # handle the exception } else { die $@; # rethrow it } Description "APR::Error" handles APR/Apache/mod_perl exceptions for you, while leaving you in control. Apache and APR API return a status code for almost all methods, so if you didn't check the return code and handled any possible problems, you may have silent failures which may cause all kind of obscure problems. On the other hand checking the status code after each call is just too much of a kludge and makes quick prototyping/development almost impossible, not talking about the code readability. Having methods return status codes, also complicates the API if you need to return other values. Therefore to keep things nice and make the API readable we decided to not return status codes, but instead throw exceptions with "APR::Error" objects for each method that fails. If you don't catch those exceptions, everything works transparently - perl will intercept the exception object and "die()" with a proper error message. So you get all the errors logged without doing any work. Now, in certain cases you don't want to just die, but instead the error needs to be trapped and handled. For example if some IO operation times out, may be it is OK to trap that and try again. If we were to die with an error message, you would have had to match the error message, which is ugly, inefficient and may not work at all if locale error strings are involved. Therefore you need to be able to get the original status code that Apache or APR has generated. And the exception objects give you that if you want to. Moreover the objects contain additional information, such as the function name (in case you were eval'ing several commands in one block), file and line number where that function was invoked from. More attributes could be added in the future. "APR::Error" uses Perl operator overloading, such that in boolean and numerical contexts, the object returns the status code; in the string context the full error message is returned. When intercepting exceptions you need to check whether $@ is an object (reference). If your application uses other exception objects you additionally need to check whether this is a an "APR::Error" object. Therefore most of the time this is enough: eval { $obj->mp_method() }; if ($@ && $ref $@ && $@ == $some_code) warn "handled exception: $@"; } But with other, non-mod_perl, exception objects you need to do: eval { $obj->mp_method() }; if ($@ && $ref $@ eq 'APR::Error' && $@ == $some_code) warn "handled exception: $@"; } In theory you could even do: eval { $obj->mp_method() }; if ($@ && $@ == $some_code) warn "handled exception: $@"; } but it's possible that the method will die with a plain string and not an object, in which case "$@ == $some_code" won't quite work. Remember that mod_perl throws exception objects only when Apache and APR fail, and in a few other special cases of its own (like "exit"). warn "handled exception: $@" if $@ && $ref $@; There are two ways to figure out whether an error fits your case. In most cases you just compare $@ with an the error constant. For example if a socket has a timeout set and the data wasn't read within the timeout limit a "APR::Const::TIMEUP") use APR::Const -compile => qw(TIMEUP); $sock->timeout_set(1_000_000); # 1 sec my $buff; eval { $sock->recv($buff, BUFF_LEN) }; if ($@ && ref $@ && $@ == APR::Const::TIMEUP) { } However there are situations, where on different Operating Systems a different error code will be returned. In which case to simplify the code you should use the special subroutines provided by the "APR::Status" class. One such condition is socket "recv()" timeout, which on Unix throws the "EAGAIN" error, but on other system it throws a different error. In this case "APR::Status::is_EAGAIN" should be used. Let's look at a complete example. Here is a code that performs a socket read: my $rlen = $sock->recv(my $buff, 1024); warn "read $rlen bytes "; and in certain cases it times out. The code will die and log the reason for the failure, which is fine, but later on you may decide that you want to have another attempt to read before dying and add some fine grained sleep time between attempts, which can be achieved with "select". Which gives us: use APR::Status (); # .... my $tries = 0; my $buffer; RETRY: my $rlen = eval { $sock->recv($buffer, SIZE) }; if ($@) die $@ unless ref $@ && APR::Status::is_EAGAIN($@); if ($tries++ < 3) { # sleep 250msec select undef, undef, undef, 0.25; goto RETRY; } else { # do something else } } warn "read $rlen bytes " Notice that we handle non-object and non-"APR::Error" exceptions as well, by simply re-throwing them. Finally, the class is called "APR::Error" because it needs to be used outside mod_perl as well, when called from "APR" applications written in Perl. API
"cluck" "cluck" is an equivalent of "Carp::cluck" that works with "APR::Error" exception objects. "confess" "confess" is an equivalent of "Carp::confess" that works with "APR::Error" exception objects. "strerror" Convert APR error code to its string representation. $error_str = APR::Error::strerror($rc); ret: $rc ( "APR::Const status constant" ) The numerical value for the return (error) code ret: $error_str ( string ) The string error message corresponding to the numerical value inside $rc. (Similar to the C function strerror(3)) since: 2.0.00 Example: Try to retrieve the bucket brigade, and if the return value doesn't indicate success or end of file (usually in protocol handlers) die, but give the user the human-readable version of the error and not just the code. my $rc = $c->input_filters->get_brigade($bb_in, Apache2::Const::MODE_GETLINE); if ($rc != APR::Const::SUCCESS && $rc != APR::Const::EOF) { my $error = APR::Error::strerror($rc); die "get_brigade error: $rc: $error "; } It's probably a good idea not to omit the numerical value in the error message, in case the error string is generated with non-English locale. See Also mod_perl 2.0 documentation. Copyright mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. Authors The mod_perl development team and numerous contributors. perl v5.14.2 2011-02-08 libapache2-mod-perl2-2.0.7::docs::api::APR::Error(3pm)
All times are GMT -4. The time now is 05:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy