Sponsored Content
Top Forums Shell Programming and Scripting awk script to check and throw error for multiplication result Post 303017026 by rdrtx1 on Tuesday 8th of May 2018 08:23:52 AM
Old 05-08-2018
Change the plus to a minus in the Error 402 check condition.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

multiplication shows syntax error

my shell script is simple arithmetic process.my addtion,substract and divide all can be worked only except multiplication.please help me.the shell is following: #!/usr/bin/sh echo "enter a number1:" read number1 echo "enter an operator:" read operator echo "enter a number2:" read number2... (4 Replies)
Discussion started by: sonicstage
4 Replies

2. Shell Programming and Scripting

throw a generic message upon error

hi all, in ksh, is there a way to throw a generic error message. i have lots of commands in my script and i didnt want to put if ; then doStuff(); else print "an error occured, please run script again"; fi around all the commands used. is there a way detect a command has... (1 Reply)
Discussion started by: cesarNZ
1 Replies

3. Shell Programming and Scripting

using awk multiplication

Suppose i have a file A 1*2*3*4 2*4*4*22 and second file B 2*3*4*5 4*4*6*7 By multiplying file A by file B that is file A by first column in file B respectively output shud be 2*6*12*20 8*16*24*154 my code is =$1 next } {for (f=1;f<=NF;f++) (2 Replies)
Discussion started by: cdfd123
2 Replies

4. UNIX for Dummies Questions & Answers

if a file is empty throw an error

I want to count the number of lines in a file and store it in a variable if this count is zero i hv to throw an error ...is this syntax correct , but i am not getting the desired result I am not using -s option here as i am concerned about record count not the size #!/bin/ksh set $count1... (4 Replies)
Discussion started by: mavesum
4 Replies

5. Shell Programming and Scripting

program for multiplication in shell script

Hi, I wanted to write a schell program that fetches the values from a file and prints the output as its onerall multiplication. for example I have a file named abc. it has values 2, 3, 4 now my program should give me 2*3*4 ie 24. note:this file abc can have any numbers. so experts,... (9 Replies)
Discussion started by: sandeep.krish
9 Replies

6. Shell Programming and Scripting

Find Command in the script throw error

Hi I have script that is developed to serch for 30 days old Directory & Files and then remove them ... when i run it successfully removes the Directory & files & but it throw errors on the screen .. .. + find . -type f -mtime +30 -exec rm -f {} ; + exit please help me ?? I... (0 Replies)
Discussion started by: Beginner123
0 Replies

7. Shell Programming and Scripting

Error with "multiplication table" in shell script

#!/bin/sh echo Enter the multiplication number required: read number for i in 1 2 3 4 5 6 7 8 9 10 do echo "$number * $i = expr $number \* $i" done I am not getting the output for this multiplication table. (4 Replies)
Discussion started by: vinodpaw
4 Replies

8. Shell Programming and Scripting

search line with more than two dots if so throw error

Hi, I have a requirement like i have to search a script and find names that conatins more than two dots, if so then throw error. For ex: a1.b1.comname here i have to find comname and check two dots. it will not throw error a1.b1.c1.comname here it contains more than 2dots it will throw... (3 Replies)
Discussion started by: swagat123
3 Replies

9. Shell Programming and Scripting

Multiplication of a column from 2 files using awk

Hi, I have two files (file1.txt, file2.txt) in which, I would like to multiply all the values in file1 with the first row value of file2, file1 * second row value of file2, file1 * third row value of file2 and so on. Below are my sample data. file1.txt file2.txt ... (6 Replies)
Discussion started by: ida1215
6 Replies

10. UNIX for Dummies Questions & Answers

Percentage / Multiplication in Shell Script

Hello, I am trying to compute the percentage in a script as shown below: PerCover=`echo "scale=2 ; 100 \* ($InputCover/$Total)" | bc` However the PerCover value is blank/null. What do I need to do differently? Thanks for your input! ~Guss (1 Reply)
Discussion started by: Gussifinknottle
1 Replies
install::TempContent::Objects::mod_perl-2.0.9::docs::apiUserRContributed Pinstall::TempContent::Objects::mod_perl-2.0.9::docs::api::APR::Status(3)

NAME
APR::Status - Perl Interface to the APR_STATUS_IS_* macros Synopsis use APR::Status (); eval { $obj->mp_method() }; if ($@ && $ref $@ eq 'APR::Error' && APR::Status::is_EAGAIN($@)) { # APR_STATUS_IS_EAGAIN(s) of apr_errno.h is satisfied } Description An interface to apr_errno.h composite error codes. As discussed in the "APR::Error" manpage, it is possible to handle APR/Apache/mod_perl exceptions in the following way: eval { $obj->mp_method() }; if ($@ && $ref $@ eq 'APR::Error' && $@ == $some_code) warn "handled exception: $@"; } However, in cases where $some_code is an APR::Const constant, there may be more than one condition satisfying the intent of this exception. For this purpose the APR C library provides in apr_errno.h a series of macros, "APR_STATUS_IS_*", which are the recommended way to check for such conditions. For example, the "APR_STATUS_IS_EAGAIN" macro is defined as #define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION) The purpose of "APR::Status" is to provide functions corresponding to these macros. Functions "is_EACCES" Check if the error is matching "EACCES" and its variants (corresponds to the "APR_STATUS_IS_EACCES" macro). $status = APR::Status::is_EACCES($error_code); arg1: $error_code (integer or "APR::Error object" ) The error code or to check, normally $@ blessed into "APR::Error object". ret: $status ( boolean ) since: 2.0.00 An example of using "is_EACCES" is when reading the contents of a file where access may be forbidden: eval { $obj->slurp_filename(0) }; if ($@) { return Apache2::Const::FORBIDDEN if ref $@ eq 'APR::Error' && APR::Status::is_EACCES($@); die $@; } Due to possible variants in conditions matching "EACCES", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::EACCES" directly. "is_EAGAIN" Check if the error is matching "EAGAIN" and its variants (corresponds to the "APR_STATUS_IS_EAGAIN" macro). $status = APR::Status::is_EAGAIN($error_code); arg1: $error_code (integer or "APR::Error object" ) The error code or to check, normally $@ blessed into "APR::Error object". ret: $status ( boolean ) since: 2.0.00 For example, here is how you may want to handle socket read exceptions and do retries: use APR::Status (); # .... my $tries = 0; my $buffer; RETRY: my $rlen = eval { $socket->recv($buffer, SIZE) }; if ($@ && ref($@) && APR::Status::is_EAGAIN($@)) { if ($tries++ < 3) { goto RETRY; } else { # do something else } } else { die "eval block has failed: $@"; } Notice that just checking against "APR::Const::EAGAIN" may work on some Unices, but then it will certainly break on win32. Thefore make sure to use this macro and not "APR::Const::EAGAIN" unless you know what you are doing. "is_ENOENT" Check if the error is matching "ENOENT" and its variants (corresponds to the "APR_STATUS_IS_ENOENT" macro). $status = APR::Status::is_ENOENT($error_code); arg1: $error_code (integer or "APR::Error object" ) The error code or to check, normally $@ blessed into "APR::Error object". ret: $status ( boolean ) since: 2.0.00 An example of using "is_ENOENT" is when reading the contents of a file which may not exist: eval { $obj->slurp_filename(0) }; if ($@) { return Apache2::Const::NOT_FOUND if ref $@ eq 'APR::Error' && APR::Status::is_ENOENT($@); die $@; } Due to possible variants in conditions matching "ENOENT", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::ENOENT" directly. "is_EOF" Check if the error is matching "EOF" and its variants (corresponds to the "APR_STATUS_IS_EOF" macro). $status = APR::Status::is_EOF($error_code); arg1: $error_code (integer or "APR::Error object" ) The error code or to check, normally $@ blessed into "APR::Error object". ret: $status ( boolean ) since: 2.0.00 Due to possible variants in conditions matching "EOF", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::EOF" directly. "is_ECONNABORTED" Check if the error is matching "ECONNABORTED" and its variants (corresponds to the "APR_STATUS_IS_ECONNABORTED" macro). $status = APR::Status::is_ECONNABORTED($error_code); arg1: $error_code (integer or "APR::Error object" ) The error code or to check, normally $@ blessed into "APR::Error object". ret: $status ( boolean ) since: 2.0.00 Due to possible variants in conditions matching "ECONNABORTED", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::ECONNABORTED" directly. "is_ECONNRESET" Check if the error is matching "ECONNRESET" and its variants (corresponds to the "APR_STATUS_IS_ECONNRESET" macro). $status = APR::Status::is_ECONNRESET($error_code); arg1: $error_code (integer or "APR::Error object" ) The error code or to check, normally $@ blessed into "APR::Error object". ret: $status ( boolean ) since: 2.0.00 Due to possible variants in conditions matching "ECONNRESET", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::ECONNRESET" directly. "is_TIMEUP" Check if the error is matching "TIMEUP" and its variants (corresponds to the "APR_STATUS_IS_TIMEUP" macro). $status = APR::Status::is_TIMEUP($error_code); arg1: $error_code (integer or "APR::Error object" ) The error code or to check, normally $@ blessed into "APR::Error object". ret: $status ( boolean ) since: 2.0.00 Due to possible variants in conditions matching "TIMEUP", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::TIMEUP" directly. 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.18.2 2015-0install::TempContent::Objects::mod_perl-2.0.9::docs::api::APR::Status(3)
All times are GMT -4. The time now is 03:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy