On Oct 23, 6:45 pm, shlo...@iglu.org.il (Shlomi Fish) wrote:
> Hi KA B,
>
> On Friday 22 October 2010 21:12:29 KA B wrote:
>
> > I`m trying to get the filehandler 1 and 2 to print the result in one
> > line.
>
> It's filehandles - not filehandlers.
>
> > The script i have made makes 2 lines.
>
> > The script goes like this:
>
> > my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
>
> Do you have strict and warnings? Also see:
>
> http://perl-begin.org/tutorials/bad-elements/
>
> And you should probably use a date+time module:
>
> http://perl-begin.org/topics/date-and-time/
>
> > $year += 1900;
> > $mon += 1;
> > open FH,"echo $year-$mon-$yday $hour:$min >> /home/me/scriptest/
> > calls_BH |";
> > while (<FH>) {
> >     print;
> > }
> > close FH;
>
> What are you trying to do here? Use three-args open (see the bad-elements link
> above), and don't resort to shell tricks for what can be done in Perl. You're
> appending the echo command's STDOUT to a file and then you're trying to pipe
> it out to Perl, but there won't be anything to pipe. This can be done in pure-
> Perl using File I/O.
>
> > open FH1," snmpget -v1 -c mee 1.2.3.1
> > 1.3.6.1.4.1.1768.100.70.40.2.1.4.2 >> /home/me/scriptest/calls_BH  |"
> > or die;
> > while (<FH1>) {
> >     print;
> > }
> > close FH1;
>
> Again, same problem. Don't use open to execute shell commands. Use system
> instead. In your case, you might wish to use backticks or open "-|" to trap
> the output of "snmpget".
>
> > The text in the file looks like this:
>
> > 2010-10-22 20:51
> > SNMPv2-SMI::enterprises.1768.100.70.40.2.1.4.2 = Counter32: 132321
>
> > I want it to look like this:
>
> > 2010-10-22 20:51 SNMPv2-SMI::enterprises.1768.100.70.40.2.1.4.2 =
> > Counter32: 132321
>
> The easiest solution in your case would be to add the -n flag to echo, which
> will supress adding a newline. But you should revamp your script from the
> ground's up.
>
>
>
> > Yeah i`m a total nuuuuub :)
> > Can somone point me in the right direction here?
>
> Please see the resources athttp://perl-begin.org/to learn Perl properly.
>
> Regards,
>
>         Shlomi Fish
>
> --
> -----------------------------------------------------------------
> Shlomi Fish      http://www.shlomifish.org/
> Optimising Code for Speed -http://shlom.in/optimise
>
> <rindolf> She's a hot chick. But she smokes.
> <go|dfish> She can smoke as long as she's smokin'.
>
> Please reply to list if it's a mailing list post -http://shlom.in/reply.

:)

Thanks for the help.
I think i`ll start again from scratch as you suggested.

I see my faults.. hehe



KAB


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to