06-30-2010
Thanks for everything. I was able to create every single file for each snmp I have to run. Twelve files; but works great! All I have to do now its doing the "dal1 227" and done!...
What I was trying to do the same thing but in a shell function; but couldnt.
No idea how to do it. I create a file for test named "sn.sh" and inside the file
I wrote the following code:
sn()
{
snmpget -c DreamTeam dal2-hr1 ifAlias.$1
}
But I have no idea how to call it and run it or if there's something wrong or missing. Can anyone help? Thanks!!
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I would like to know , how to concatenate two command in one line and get the display in one screen
for eg
command 1 : ls -l /data/logs
command 2 : ls -l /data/errors
output shd be
/data/logs /data/errors
xx-xx-xx-xx abc.log xx-xx-xx-xx... (9 Replies)
Discussion started by: vasikaran
9 Replies
2. UNIX for Advanced & Expert Users
I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line.
2 lines from log:
2007-10-23 11:39:17,061 DEBUG - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN... (1 Reply)
Discussion started by: vithala
1 Replies
3. Shell Programming and Scripting
I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line.
2 lines from log:
2007-10-23 11:39:17,061 DEBUG - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN... (7 Replies)
Discussion started by: vithala
7 Replies
4. Shell Programming and Scripting
Hi All,
i have a zip file like the format
794051400123|COM|24|0|BD|R|99.98
794051413727|COM|11|0|BD|R|28.99
794051415622|COM|23|0|BD|R|28.99
883929004676|COM|0|0|BD|R|28.99
794051400123|MOM|62|0|BD|R|99.98
794051413727|MOM|4|0|BD|R|28.99
794051415622|MOM|80|0|BD|R|28.99
... (30 Replies)
Discussion started by: vaskarbasak
30 Replies
5. UNIX for Advanced & Expert Users
Hi
I am getting a source file where the columns are seperated by comma and double Quotes
Eg1 : "AAA","BBB","CCCC"
in the same source file i am also getting few lines where my last columns double quotes are ending in its next line or the next next line
Eg2: "AAA","BBB","CCC
CC"... (9 Replies)
Discussion started by: laxmi131
9 Replies
6. Shell Programming and Scripting
Hi, I have a noob question . Can someone help me how to concatenate line by line using this variables?
var1:
Apple|
Banana|
var2:
Red
Yellow
then how can I concatenate both line by line? in which the result would be:
Apple|Red
Banana|Yellow
just to generate a row result i was... (6 Replies)
Discussion started by: hagdanan
6 Replies
7. Shell Programming and Scripting
I've got a log file from automatic diagnostic runs. The log file is appended to each time an automatic log is run.
I'd like to just pull certain lines from each run in the log file, and concatenate them into 1 comma delimited line (for export into excel or an html table).
Each diagnostic run... (3 Replies)
Discussion started by: BecTech
3 Replies
8. Shell Programming and Scripting
I have several hundreds of tiny files which need to be concatenated into one single line and all those in a single file. Some files have several blank lines. Tried to use this script but failed on it.
awk 'END { print r } r && !/^/ { print FILENAME, r; r = "" }{ r = r ? r $0 : $0 }' *.txt... (8 Replies)
Discussion started by: sdf
8 Replies
9. Shell Programming and Scripting
Hello to all,
I'm new to perl, I have input file that contains the string below:
315350535ff450000014534130101ff4500ff45453779ff450ff45545f01ff45ff453245341ff4500000545000This string has as line separator "ff45". So, I want to print each line but the code below is not working.
perl -pe '... (2 Replies)
Discussion started by: Ophiuchus
2 Replies
10. Shell Programming and Scripting
Hi,
Do anybody experience how to concatenate multiple line into one line by using awk or perl command?
Input file:
>set1
QAWEQRQ@EWQEASED
ASDAEQW
QAWEQRQTQ
ASRFQWRGWQ
From the above Input file, it got 5 lines
Desired output file:
>set1... (6 Replies)
Discussion started by: perl_beginner
6 Replies
LEARN ABOUT MOJAVE
test::fatal
Test::Fatal(3) User Contributed Perl Documentation Test::Fatal(3)
NAME
Test::Fatal - incredibly simple helpers for testing code with exceptions
VERSION
version 0.013
SYNOPSIS
use Test::More;
use Test::Fatal;
use System::Under::Test qw(might_die);
is(
exception { might_die; },
undef,
"the code lived",
);
like(
exception { might_die; },
qr/turns out it died/,
"the code died as expected",
);
isa_ok(
exception { might_die; },
'Exception::Whatever',
'the thrown exception',
);
DESCRIPTION
Test::Fatal is an alternative to the popular Test::Exception. It does much less, but should allow greater flexibility in testing
exception-throwing code with about the same amount of typing.
It exports one routine by default: "exception".
FUNCTIONS
exception
my $exception = exception { ... };
"exception" takes a bare block of code and returns the exception thrown by that block. If no exception was thrown, it returns undef.
Achtung! If the block results in a false exception, such as 0 or the empty string, Test::Fatal itself will die. Since either of these
cases indicates a serious problem with the system under testing, this behavior is considered a feature. If you must test for these
conditions, you should use Try::Tiny's try/catch mechanism. (Try::Tiny is the underlying exception handling system of Test::Fatal.)
Note that there is no TAP assert being performed. In other words, no "ok" or "not ok" line is emitted. It's up to you to use the rest of
"exception" in an existing test like "ok", "isa_ok", "is", et cetera. Or you may wish to use the "dies_ok" and "lives_ok" wrappers, which
do provide TAP output.
"exception" does not alter the stack presented to the called block, meaning that if the exception returned has a stack trace, it will
include some frames between the code calling "exception" and the thing throwing the exception. This is considered a feature because it
avoids the occasionally twitchy "Sub::Uplevel" mechanism.
Achtung! This is not a great idea:
sub exception_like(&$;$) {
my ($code, $pattern, $name) = @_;
like( &exception($code), $pattern, $name );
}
exception_like(sub { }, qr/foo/, 'foo appears in the exception');
If the code in the "..." is going to throw a stack trace with the arguments to each subroutine in its call stack (for example via
"Carp::confess", the test name, "foo appears in the exception" will itself be matched by the regex. Instead, write this:
like( exception { ... }, qr/foo/, 'foo appears in the exception' );
Achtung: One final bad idea:
isnt( exception { ... }, undef, "my code died!");
It's true that this tests that your code died, but you should really test that it died for the right reason. For example, if you make an
unrelated mistake in the block, like using the wrong dereference, your test will pass even though the code to be tested isn't really run at
all. If you're expecting an inspectable exception with an identifier or class, test that. If you're expecting a string exception,
consider using "like".
success
try {
should_live;
} catch {
fail("boo, we died");
} success {
pass("hooray, we lived");
};
"success", exported only by request, is a Try::Tiny helper with semantics identical to "finally", but the body of the block will only be
run if the "try" block ran without error.
Although almost any needed exception tests can be performed with "exception", success blocks may sometimes help organize complex testing.
dies_ok
lives_ok
Exported only by request, these two functions run a given block of code, and provide TAP output indicating if it did, or did not throw an
exception. These provide an easy upgrade path for replacing existing unit tests based on "Test::Exception".
RJBS does not suggest using this except as a convenience while porting tests to use Test::Fatal's "exception" routine.
use Test::More tests => 2;
use Test::Fatal qw(dies_ok lives_ok);
dies_ok { die "I failed" } 'code that fails';
lives_ok { return "I'm still alive" } 'code that does not fail';
AUTHOR
Ricardo Signes <rjbs@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.18.2 2013-09-23 Test::Fatal(3)