Loading ...
Sorry, an error occurred while loading the content.

outputting a command result

Expand Messages
  • ReginaM
    Hi, I d like to ftp the newest file in a directory from a unix box to our windows network. To do this, I plan to use the following to find the newest file:
    Message 1 of 6 , Oct 27, 2011
    • 0 Attachment
      Hi,
      I'd like to ftp the newest file in a directory from a unix box to our windows network.

      To do this, I plan to use the following to find the newest file:
      $filename = "ls -at1 /head -1";

      Then I want to use that file name in my ftp file that I'll create. So I want to output the results, with the word print in front:
      print "put $filename\n";

      What I get as a result is:
      put ls -at1 /head -1

      How do I get it to put the results of the command into my variable, instead of the command itself?

      Thanks!
      Regina
    • Rajagopal, Jay
      Instead of , Use back quotes `` that are near key button 1 . ... From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf Of
      Message 2 of 6 , Oct 27, 2011
      • 0 Attachment
        Instead of "" , Use back quotes `` that are near key button 1 .

        -----Original Message-----
        From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf Of ReginaM
        Sent: Thursday, October 27, 2011 5:30 PM
        To: perl-beginner@yahoogroups.com
        Subject: [PBML] outputting a command result

        Hi,
        I'd like to ftp the newest file in a directory from a unix box to our windows network.

        To do this, I plan to use the following to find the newest file:
        $filename = "ls -at1 /head -1";

        Then I want to use that file name in my ftp file that I'll create. So I want to output the results, with the word print in front:
        print "put $filename\n";

        What I get as a result is:
        put ls -at1 /head -1

        How do I get it to put the results of the command into my variable, instead of the command itself?

        Thanks!
        Regina





        ------------------------------------

        Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links




        T. Rowe Price (including T. Rowe Price Group, Inc. and its affiliates) and its associates do not provide legal or tax advice. Any tax-related discussion contained in this e-mail, including any attachments, is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding any tax penalties or (ii) promoting, marketing, or recommending to any other party any transaction or matter addressed herein. Please consult your independent legal counsel and/or professional tax advisor regarding any legal or tax issues raised in this e-mail.

        The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail.
      • Amish Husain
        use backtick ` instead of ________________________________ From: ReginaM To: perl-beginner@yahoogroups.com Sent: Thursday,
        Message 3 of 6 , Oct 27, 2011
        • 0 Attachment
          use backtick ` instead of "


          ________________________________
          From: ReginaM <rmiller@...-harbor.wa.us>
          To: perl-beginner@yahoogroups.com
          Sent: Thursday, October 27, 2011 5:29 PM
          Subject: [PBML] outputting a command result


           
          Hi,
          I'd like to ftp the newest file in a directory from a unix box to our windows network.

          To do this, I plan to use the following to find the newest file:
          $filename = "ls -at1 /head -1";

          Then I want to use that file name in my ftp file that I'll create. So I want to output the results, with the word print in front:
          print "put $filename\n";

          What I get as a result is:
          put ls -at1 /head -1

          How do I get it to put the results of the command into my variable, instead of the command itself?

          Thanks!
          Regina




          [Non-text portions of this message have been removed]
        • ReginaM
          Jay, Thank you. That got me farther along, but I still have an issue. I ve now got: $filename = `ls -at1 /head -1`; print put $c n ; What I get is: /head: No
          Message 4 of 6 , Oct 27, 2011
          • 0 Attachment
            Jay,
            Thank you.
            That got me farther along, but I still have an issue.

            I've now got:
            $filename = `ls -at1 /head -1`;
            print "put $c\n";

            What I get is:
            /head: No such file or directory
            -1; No such file or directory.

            Then I get the output of my print command as:
            put

            Thanks,
            Regina

            --- In perl-beginner@yahoogroups.com, "Rajagopal, Jay" <jay_rajagopal@...> wrote:
            >
            > Instead of "" , Use back quotes `` that are near key button 1 .
            >
            > -----Original Message-----
            > From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf Of ReginaM
            > Sent: Thursday, October 27, 2011 5:30 PM
            > To: perl-beginner@yahoogroups.com
            > Subject: [PBML] outputting a command result
            >
            > Hi,
            > I'd like to ftp the newest file in a directory from a unix box to our windows network.
            >
            > To do this, I plan to use the following to find the newest file:
            > $filename = "ls -at1 /head -1";
            >
            > Then I want to use that file name in my ftp file that I'll create. So I want to output the results, with the word print in front:
            > print "put $filename\n";
            >
            > What I get as a result is:
            > put ls -at1 /head -1
            >
            > How do I get it to put the results of the command into my variable, instead of the command itself?
            >
            > Thanks!
            > Regina
            >
            >
            >
            >
            >
            > ------------------------------------
            >
            > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links
            >
            >
            >
            >
            > T. Rowe Price (including T. Rowe Price Group, Inc. and its affiliates) and its associates do not provide legal or tax advice. Any tax-related discussion contained in this e-mail, including any attachments, is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding any tax penalties or (ii) promoting, marketing, or recommending to any other party any transaction or matter addressed herein. Please consult your independent legal counsel and/or professional tax advisor regarding any legal or tax issues raised in this e-mail.
            >
            > The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail.
            >
          • merlyn@stonehenge.com
            ... ReginaM Thank you. ReginaM That got me farther along, but I still have an issue. ReginaM I ve now got: ReginaM $filename = `ls -at1 /head -1`; If
            Message 5 of 6 , Oct 27, 2011
            • 0 Attachment
              >>>>> "ReginaM" == ReginaM <rmiller@...-harbor.wa.us> writes:

              ReginaM> Thank you.
              ReginaM> That got me farther along, but I still have an issue.

              ReginaM> I've now got:
              ReginaM> $filename = `ls -at1 /head -1`;

              If that's supposed to be:

              ls -at1 | head -1

              It'd be simpler to just:

              my ($filename) = `ls -at1`;

              which will grab just the first line of output.

              --
              Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
              <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
              Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
              See http://methodsandmessages.posterous.com/ for Smalltalk discussion
            • rmillergraysharbor
              That s it! Thanks to all of you for your help. Regina
              Message 6 of 6 , Oct 27, 2011
              • 0 Attachment
                That's it!
                Thanks to all of you for your help.
                Regina

                --- In perl-beginner@yahoogroups.com, merlyn@... wrote:
                >
                > >>>>> "ReginaM" == ReginaM <rmiller@...> writes:
                >
                > ReginaM> Thank you.
                > ReginaM> That got me farther along, but I still have an issue.
                >
                > ReginaM> I've now got:
                > ReginaM> $filename = `ls -at1 /head -1`;
                >
                > If that's supposed to be:
                >
                > ls -at1 | head -1
                >
                > It'd be simpler to just:
                >
                > my ($filename) = `ls -at1`;
                >
                > which will grab just the first line of output.
                >
                > --
                > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                > <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                > Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
                > See http://methodsandmessages.posterous.com/ for Smalltalk discussion
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.