$progress = 2; if( $progress == 2){ for(;;){ if( $progress == 0){last} } }

What do you expect this code snippet to do? I expect it to sit in the for (;;) loop forever, since there's nothing in the loop that would set $progress=0 - or is this a variable shared between threads? Anyways, such a tight loop which tests just one variable is a wonderful way to hog your machine's CPU.

Why are you testing $progress just after setting it? ....ah, now. This is some variable you can control from TK, right?

Searching... ah, this essentally is code you got from zentara as an answer to a previous post from you, with formatting gone wild.

Stripping all those $progress blocks (you could have done that before posting), what remains is this:

sub sftp{ $|++; while(1){ if($die == 1){ goto END }; if ( $go == 1 ){ my $seconds = 120; my %args = (host=>$server, user=>$user, timeout=>$seconds) +; my $sftp = Net::SFTP::Foreign->new(%args); if ($sftp->error){ goto line; } $sftp->put("$waylcl\\waytemp", "$wayrmt/waytemp"); if ($sftp->error){ goto line; } line: if($die == 1){ goto END }; undef $sftp; #close current sftp $go = 0; #turn off self before returning } else { sleep 1 } # sleep if $go == 0 } END: }

The second goto line; - apart from goto being bad practice - doesn't make any sense; shouldn't that be goto END ? Removing all that goto stuff, your code becomes

sub sftp{ $|++; while(1){ last if $die == 1; if ( $go == 1 ){ my $seconds = 120; my %args = (host=>$server, user=>$user, timeout=>$seconds) +; my $sftp = Net::SFTP::Foreign->new(%args); last if ($sftp->error); $sftp->put("$waylcl\\waytemp", "$wayrmt/waytemp"); last if ($sftp->error); last if $die == 1; undef $sftp; #close current sftp $go = 0; #turn off self before returning } else { sleep 1; } # sleep if $go == 0 } }

Now, the only relevant line I see is

$sftp->put("$waylcl\\waytemp", "$wayrmt/waytemp");

Does the directory $wayrmt exist on the remote server?

(I keep getting in trouble for my posts)

That's because you really make it difficult to help you.
Fix your code formatting, throw out stuff that isn't relevant. See How (Not) To Ask A Question.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to Re: Connecting to a Server by shmem
in thread Connecting to a Server by deadpickle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.