Sponsored Content
Full Discussion: Problem with perl openssh
Top Forums Shell Programming and Scripting Problem with perl openssh Post 302466804 by durden_tyler on Wednesday 27th of October 2010 10:50:07 AM
Old 10-27-2010
Quote:
Originally Posted by samohung390
...
my problem is that it keeps returning errors that I dont understand, it says:
use of uninitialized value $default_stdin_fh in anonymous hash....
almost the whole errors says like this but changes to $default_stdout_fh,$default_stderr_fh,$master_stdi n_fh........

what does these error mean?
It means exactly what it says.
$default_stdin_fh has not been initialized, and therefore perl shows that warning.

A very short example might help in understanding this better -

Code:
$
$ perl -wle 'my $x; if ($x eq "hello") {print "HELLO"}'
Use of uninitialized value $x in string eq at -e line 1.
$
$

I declared the scalar $x, but did not initialize it. Perl doesn't know how to compare a literal string "hello" with an uninitialized value of $x. So it shows the warning.

Note that it's a warning, not an error. If I remove the "-w" flag, then this will not be shown.

Code:
$
$ perl -le 'my $x; if ($x eq "hello") {print "HELLO"}'
$

That's the same as removing the "use warnings" statement from a Perl program file - although it's highly recommended to retain it.

Of course, the problem isn't fixed by turning warnings off. You'll have to actually initialize the scalar/array/hash/whatever to make your program work.

tyler_durden
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Problem installing openssh v2.9-p2

I am trying to install openssh v2.9-p2 on Solaris 8. I already installed zlib and openssl, as required in INSTALL file. But when I issue ./configure to configure openssh v2.9-p2 for my platform ( I got the sources), it stops in the folowing message: checking for OpenSSL directory... configure:... (1 Reply)
Discussion started by: htsubamoto
1 Replies

2. UNIX for Dummies Questions & Answers

OpenSSH

Help! SSH is returning the following error message: OpenSSL version mismatch. Built against 90581f, you have 90602f How can I correct this? (21 Replies)
Discussion started by: chenly
21 Replies

3. Shell Programming and Scripting

problem with perl

hi, i have a script that coverts the file time in epoch time.but the problem is perl is not working inside the k-shell ---------------------------------------------------------------- #!/bin/ksh echo "Enter the file" read n perl -e 'print ((stat("n")))'... (6 Replies)
Discussion started by: ali560045
6 Replies

4. UNIX for Dummies Questions & Answers

A problem about openssh

When I first link a computer with ssh , the information "Warning: Permanently added ... (RSA) to the list of known hosts." will be occured. How can i avoid this information without use the parameter '-q'? tks!!! (2 Replies)
Discussion started by: ragehunter
2 Replies

5. UNIX Desktop Questions & Answers

OpenSSH

Hello, I downloaded Cygwin to practice on my coursework from home. I was told to download the OpenSSH from Cygwin website so that I can access my files from home. However, the file saves itself with a cgi extension and I have no idea as to what I am supposed to do next. I found info on some... (1 Reply)
Discussion started by: feliks0
1 Replies

6. AIX

AIX 6.1 - openssh - problem

Hello, I am new in aix unix. First i install openssl - success, next step i try install openssh when i put command geninstall -Y -d /myssh openssh.base i have this message: What is the problem? Thanks for help. Sorry for my bad english i still learning. ---------- Post updated at... (2 Replies)
Discussion started by: bieszczaders
2 Replies

7. Fedora

OpenSSH Problem

Hello, I cannot seem to loggon to a machine using ssh/scp. Whenevr I do it closes the connection (error message : lost connection)but it appears to be the host machine closing rather than the destination which puzzles me even more. What is even weirder is that as a root user it works but as a... (1 Reply)
Discussion started by: mojoman
1 Replies

8. UNIX for Advanced & Expert Users

Problem with OpenSSH Remote Port Forwarding with Bind_address

As in the ssh(1) man page: -R bind_address:]port:host:hostport .......By default, the listening socket on the server will be bound to the loopback interface only. This may be overridden by specifying a bind_address. An empty bind_address, or the address `*', indicates... (2 Replies)
Discussion started by: ahmad.zuhd
2 Replies

9. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

10. Red Hat

Openssh 6.8

Hi im using redhat enterprise linux 7 im trying to update to the latest openssh version 6.8 i ran the command yum update openssh and this upgraded only to version 6.6 how can i update to the latest version 6.8? thanks! (5 Replies)
Discussion started by: guy3145
5 Replies
Warn(3pm)						User Contributed Perl Documentation						 Warn(3pm)

NAME
Test::Warn - Perl extension to test methods for warnings SYNOPSIS
use Test::Warn; warning_is {foo(-dri => "/")} "Unknown Parameter 'dri'", "dri != dir gives warning"; warnings_are {bar(1,1)} ["Width very small", "Height very small"]; warning_is {add(2,2)} undef, "No warnings for calc 2+2"; # or warnings_are {add(2,2)} [], "No warnings for calc 2+2"; # what reads better :-) warning_like {foo(-dri => "/")} qr/unknown param/i, "an unknown parameter test"; warnings_like {bar(1,1)} [qr/width.*small/i, qr/height.*small/i]; warning_is {foo()} {carped => "didn't find the right parameters"}; warnings_like {foo()} [qr/undefined/,qr/undefined/,{carped => qr/no result/i}]; warning_like {foo(undef)} 'uninitialized'; warning_like {bar(file => '/etc/passwd')} 'io'; warning_like {eval q/"$x"; $x;/} [qw/void uninitialized/], "some warnings at compile time"; warnings_exist {...} [qr/expected warning/], "Expected warning is thrown"; DESCRIPTION
A good style of Perl programming calls for a lot of diverse regression tests. This module provides a few convenience methods for testing warning based-code. If you are not already familiar with the Test::More manpage, now would be the time to go take a look. FUNCTIONS warning_is BLOCK STRING, TEST_NAME Tests that BLOCK gives the specified warning exactly once. The test fails if the BLOCK warns more than once or does not warn at all. If the string is undef, then the tests succeeds if the BLOCK doesn't give any warning. Another way to say that there are no warnings in the block is "warnings_are {foo()} [], "no warnings"". If you want to test for a warning given by Carp you have to write something like: "warning_is {carp "msg"} {carped => 'msg'}, "Test for a carped warning"". The test will fail if a "normal" warning is found instead of a "carped" one. Note: "warn "foo"" would print something like "foo at -e line 1". This method ignores everything after the "at". Thus to match this warning you would have to call "warning_is {warn "foo"} "foo", "Foo succeeded"". If you need to test for a warning at an exactly line, try something like "warning_like {warn "foo"} qr/at XYZ.dat line 5/". warning_is and warning_are are only aliases to the same method. So you also could write "warning_is {foo()} [], "no warning"" or something similar. I decided to give two methods the same name to improve readability. A true value is returned if the test succeeds, false otherwise. The test name is optional, but recommended. warnings_are BLOCK ARRAYREF, TEST_NAME Tests to see that BLOCK gives exactly the specified warnings. The test fails if the warnings from BLOCK are not exactly the ones in ARRAYREF. If the ARRAYREF is equal to [], then the test succeeds if the BLOCK doesn't give any warning. Please read also the notes to warning_is as these methods are only aliases. If you want more than one test for carped warnings, try this: "warnings_are {carp "c1"; carp "c2"} {carped =" ['c1','c2'];> or "warnings_are {foo()} ["Warning 1", {carped =" ["Carp 1", "Carp 2"]}, "Warning 2"]>. Note that "{carped =" ...}> must always be a hash ref. warning_like BLOCK REGEXP, TEST_NAME Tests that BLOCK gives exactly one warning and it can be matched by the given regexp. If the string is undef, then the tests succeeds iff the BLOCK doesn't give any warning. The REGEXP is matched against the whole warning line, which in general has the form "WARNING at __FILE__ line __LINE__". So you can check for a warning in the file Foo.pm on line 5 with "warning_like {bar()} qr/at Foo.pm line 5/, "Testname"". Perhaps it is not sensible to perform such a test; however, you should be aware that matching on a sweeping regular expression or similar will always pass. Consider qr/^foo/ if you want to test for warning "foo something" in file foo.pl. You can also write the regexp in a string as "/.../" instead of using the qr/.../ syntax. Note that the slashes are important in the string, as strings without slashes are reserved for warning categories (to match warning categories as can be seen in the perllexwarn man page). As with "warning_is", you can test for warnings via "carp" with: "warning_like {bar()} {carped =" qr/bar called too early/i};> Similar to "warning_is"/"warnings_are", "warning_like" and "warnings_like" are only aliases to the same methods. A true value is returned if the test succeeds, false otherwise. The test name is optional, but recommended. warning_like BLOCK STRING, TEST_NAME Tests whether a BLOCK gives exactly one warning of the passed category. The categories are grouped in a tree, like it is expressed in perllexwarn. Note that they have the hierarchical structure from perl 5.8.0, you can access the internal hierarchy with $Test::Warn::Categorization::tree, although it isn't recommended). Thanks to the grouping in a tree, it's possible to test simply for an 'io' warning, instead of testing for a 'closed|exec|layer|newline|pipe|unopened' warning. Note that compile-time warnings can only be caught in an eval block. So warning_like {eval q/"$x"; $x;/} [qw/void uninitialized/], "some warnings at compile time"; will work, while it wouldn't work without the eval. Note also that it isn't yet possible to test for categories you created yourself with "warnings::register". warnings_like BLOCK ARRAYREF, TEST_NAME Tests to see that BLOCK gives exactly the number of the specified warnings and all the warnings have to match in the defined order to the passed regexes. Please read also the notes to warning_like as these methods are only aliases. Similar to "warnings_are", you can test for multiple warnings via "carp" and for warning categories, too: warnings_like {foo()} [qr/bar warning/, qr/bar warning/, {carped => qr/bar warning/i}, 'io' ], "I hope you'll never have to write a test for so many warnings :-)"; warnings_exist BLOCK STRING|ARRAYREF, TEST_NAME Same as warning_like, but will warn() all warnings that do not match the supplied regex/category, instead of registering an error. Use this test when you just want to make sure that specific warnings were generated, and couldn't care less if other warnings happened in the same block of code. warnings_exist {...} [qr/expected warning/], "Expected warning is thrown"; warnings_exist {...} ['uninitialized'], "Expected warning is thrown"; EXPORT "warning_is", "warnings_are", "warning_like", "warnings_like", "warnings_exist" by default. BUGS
Please note that warnings with newlines inside are very awkward. The only sensible way to handle them is to use the "warning_like" or "warnings_like" methods. The background is that there is no really safe way to distinguish between warnings with newlines and a stacktrace. If a method has its own warn handler, overwriting $SIG{__WARN__}, my test warning methods won't get these warnings. The "warning_like BLOCK CATEGORY, TEST_NAME" method isn't fully tested. Please take note if you use this this calling style, and report any bugs you find. TODO
Improve this documentation. The code has some parts doubled - especially in the test scripts. This is really awkward and must be changed. Please feel free to suggest improvements. SEE ALSO
Have a look to the similar Test::Exception module. Test::Trap THANKS
Many thanks to Adrian Howard, chromatic and Michael G. Schwern, who have given me a lot of ideas. AUTHOR
Janek Schleicher, <bigj AT kamelfreund.de> COPYRIGHT AND LICENSE
Copyright 2002 by Janek Schleicher Copyright 2007-2011 by Alexandr Ciornii, <http://chorny.net/> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2011-06-16 Warn(3pm)
All times are GMT -4. The time now is 03:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy