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

Re: [redhat] Scripts

Expand Messages
  • Scott Robbins
    ... What about caling script2 as a function in script1? I guess the other question is how does script2 exit? (However, I m a novice scripter and no doubt,
    Message 1 of 12 , Sep 4, 2003
    • 0 Attachment
      On Thu, Sep 04, 2003 at 10:33:07AM +0200, Werner vd Merwe wrote:
      > Good day,
      >
      > I need to write a script that will call script2, and at the end of script2,
      > will call it again.
      > Initially, I did the following:
      >
      > # Script1
      > /usr/test/script2
      > /script1
      >
      > The problem with this, was it stacks the processes.

      What about caling script2 as a function in script1?
      I guess the other question is how does script2 exit?

      (However, I'm a novice scripter and no doubt, you'll get far better
      answers as more people see this.) :)

      --

      Scott Robbins

      PGP keyID EB3467D6
      ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 D575 EB34 67D6 )
      gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

      Xander: Yeah, I'm gonna have to go with dead boy on this one.
      Angel: Could you not call me that?
    • Werner vd Merwe
      A function of script1? My knowledge of scripting is next to zero :-) Could you maybe give me an example? The called script will exit and kill all threads every
      Message 2 of 12 , Sep 4, 2003
      • 0 Attachment
        A function of script1?

        My knowledge of scripting is next to zero :-)

        Could you maybe give me an example?
        The called script will exit and kill all threads every 5odd minutes.


        -----Original Message-----
        From: Scott Robbins [mailto:scottro@...]
        Sent: 04 September 2003 12:08 PM
        To: redhat@yahoogroups.com
        Subject: Re: [redhat] Scripts

        On Thu, Sep 04, 2003 at 10:33:07AM +0200, Werner vd Merwe wrote:
        > Good day,
        >
        > I need to write a script that will call script2, and at the end of
        script2,
        > will call it again.
        > Initially, I did the following:
        >
        > # Script1
        > /usr/test/script2
        > /script1
        >
        > The problem with this, was it stacks the processes.

        What about caling script2 as a function in script1?
        I guess the other question is how does script2 exit?

        (However, I'm a novice scripter and no doubt, you'll get far better
        answers as more people see this.) :)

        --

        Scott Robbins

        PGP keyID EB3467D6
        ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 D575 EB34 67D6 )
        gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

        Xander: Yeah, I'm gonna have to go with dead boy on this one.
        Angel: Could you not call me that?




        Yahoo! Groups Sponsor
        ADVERTISEMENT
        click here
        <http://rd.yahoo.com/M=259538.3830715.5078802.1261774/D=egroupweb/S=17050065
        80:HM/A=1712983/R=0/SIG=11u38u3s2/*http://hits.411web.com/cgi-bin/hit?page=1
        374-105951838331032>


        To unsubscribe, email to redhat-unsubscribe@yahoogroups.com
        To post to the redhat group, send your post to redhat@yahoogroups.com
        To reach the moderators, email to redhat-owner@yahoogroups.com


        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
        <http://docs.yahoo.com/info/terms/> .


        [Non-text portions of this message have been removed]
      • James Drabb
        ... Why can t you just call script2 twice? #!/bin/bash /path/to/script2 sleep 1 /path/to/script2 Script1 will wait until script2 finishes and then sleep for 1
        Message 3 of 12 , Sep 4, 2003
        • 0 Attachment
          On Thu, 2003-09-04 at 04:33, Werner vd Merwe wrote:
          > Good day,
          >
          > I need to write a script that will call script2, and at the end of script2,
          > will call it again.
          > Initially, I did the following:
          >
          > # Script1
          > /usr/test/script2
          > /script1
          >
          > The problem with this, was it stacks the processes.
          >
          > Any ideas?
          >
          > Werner vd Merwe
          > SAICOM
          > Tel: +27 21 5550726
          > Cell: 083 449 4839
          > A member of Walk and Talk Services

          Why can't you just call script2 twice?

          #!/bin/bash
          /path/to/script2
          sleep 1
          /path/to/script2

          Script1 will wait until script2 finishes and then sleep for 1 second
          and call script2 a second time.

          Jim Drabb
          --
          ----------------------------------------------------------
          The box said: "Requires Windows 98/2000/XP/NT, or better."
          So, I installed LINUX!
          ----------------------------------------------------------
          James Drabb JR
          Senior Programmer Analyst
          Darden Restaurants
          Business Systems
          JDrabb at Darden dot com
        • Werner vd Merwe
          James, Thank you for your reply, that is how we had it, but it stacks processes, if I check a couple of minutes later, there is about 20-30 instances of bash
          Message 4 of 12 , Sep 4, 2003
          • 0 Attachment
            James,

            Thank you for your reply, that is how we had it, but it stacks processes, if
            I check a couple of minutes later, there is about 20-30 instances of bash
            running.

            -----Original Message-----
            From: James Drabb [mailto:JDrabb@...]
            Sent: 04 September 2003 03:17 PM
            To: RedHat
            Subject: Re: [redhat] Scripts

            On Thu, 2003-09-04 at 04:33, Werner vd Merwe wrote:
            > Good day,
            >
            > I need to write a script that will call script2, and at the end of
            script2,
            > will call it again.
            > Initially, I did the following:
            >
            > # Script1
            > /usr/test/script2
            > /script1
            >
            > The problem with this, was it stacks the processes.
            >
            > Any ideas?
            >
            > Werner vd Merwe
            > SAICOM
            > Tel: +27 21 5550726
            > Cell: 083 449 4839
            > A member of Walk and Talk Services

            Why can't you just call script2 twice?

            #!/bin/bash
            /path/to/script2
            sleep 1
            /path/to/script2

            Script1 will wait until script2 finishes and then sleep for 1 second
            and call script2 a second time.

            Jim Drabb
            --
            ----------------------------------------------------------
            The box said: "Requires Windows 98/2000/XP/NT, or better."
            So, I installed LINUX!
            ----------------------------------------------------------
            James Drabb JR
            Senior Programmer Analyst
            Darden Restaurants
            Business Systems
            JDrabb at Darden dot com



            Yahoo! Groups Sponsor
            ADVERTISEMENT
            click here
            <http://rd.yahoo.com/M=259538.3830715.5078802.1261774/D=egroupweb/S=17050065
            80:HM/A=1712983/R=0/SIG=11u38u3s2/*http://hits.411web.com/cgi-bin/hit?page=1
            374-105951838331032>


            To unsubscribe, email to redhat-unsubscribe@yahoogroups.com
            To post to the redhat group, send your post to redhat@yahoogroups.com
            To reach the moderators, email to redhat-owner@yahoogroups.com


            Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
            <http://docs.yahoo.com/info/terms/> .


            [Non-text portions of this message have been removed]
          • James Drabb
            ... Then use the exec call. It will replace the running process with the command you specify. For expample, from script 2, you can have script2 replaces
            Message 5 of 12 , Sep 4, 2003
            • 0 Attachment
              On Thu, 2003-09-04 at 09:21, Werner vd Merwe wrote:
              > James,
              >
              > Thank you for your reply, that is how we had it, but it stacks processes, if
              > I check a couple of minutes later, there is about 20-30 instances of bash
              > running.

              Then use the exec call. It will replace the running process with
              the command you specify. For expample, from script 2, you can have
              script2 replaces itself with a new instance of script2 by doing:
              exec /path/to/script2.

              Or from script1:

              #!/bin/bash
              /path/to/script2
              sleep 1
              # replace ourself with scrip2 for the last call so that
              # when script2 ends, script1 and script2 will be gone
              exec /path/to/script2

              Jim Drabb
              --
              ----------------------------------------------------------
              The box said: "Requires Windows 98/2000/XP/NT, or better."
              So, I installed LINUX!
              ----------------------------------------------------------
              James Drabb JR
              Senior Programmer Analyst
              Darden Restaurants
              Business Systems
              JDrabb at Darden dot com
            • Scott Robbins
              ... Yeah, so is mine. But it would work (in ksh, not sure if it s different in bash in script1 SCRIPT2() { script2 } Then, you can call the function in
              Message 6 of 12 , Sep 4, 2003
              • 0 Attachment
                On Thu, Sep 04, 2003 at 02:25:26PM +0200, Werner vd Merwe wrote:
                > A function of script1?
                >
                > My knowledge of scripting is next to zero :-)

                Yeah, so is mine. But it would work (in ksh, not sure if it's different
                in bash

                in script1

                SCRIPT2() {
                script2
                }

                Then, you can call the function in script1 by
                SCRIPT2

                (In bash, you might have to do it as

                function SCRIPT2()

                But I'm not sure. )

                However, definitely listen to James over me. :)

                --

                Scott

                GPG KeyID EB3467D6
                ( 1B848 077D 66F6 9DB0 FDC2 A409 FA54 D575 EB34 67D6)
                gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

                Cordelia: I came over here to tell Buffy to stop this
                craziness, and
                found you all unconscious--again. How many times have you been
                knocked out, anyway? I swear, one of these times, you're going
                to wake up in a coma.
                Giles: Wake up in a...? Oh, never mind. We need to save Buffy from
                Hansel and Gretel.
                Cordelia: Now, let's be clear. The brain damage happened before I hit
                you.


                [Non-text portions of this message have been removed]
              • James Drabb
                ... There are basically three ways to run another process. /path/to/foo This will run the process with ANOTHER bash instance. The new process will not have
                Message 7 of 12 , Sep 4, 2003
                • 0 Attachment
                  On Thu, 2003-09-04 at 10:36, Scott Robbins wrote:
                  > On Thu, Sep 04, 2003 at 02:25:26PM +0200, Werner vd Merwe wrote:
                  > > A function of script1?
                  > >
                  > > My knowledge of scripting is next to zero :-)
                  >
                  > Yeah, so is mine. But it would work (in ksh, not sure if it's different
                  > in bash
                  >
                  > in script1
                  >
                  > SCRIPT2() {
                  > script2
                  > }
                  >
                  > Then, you can call the function in script1 by
                  > SCRIPT2
                  >
                  > (In bash, you might have to do it as
                  >
                  > function SCRIPT2()
                  >
                  > But I'm not sure. )
                  >
                  > However, definitely listen to James over me. :)

                  There are basically three ways to run another process.

                  /path/to/foo
                  This will run the process with ANOTHER bash instance. The new process
                  will not have the same environment variables as the current process.

                  . /path/to/foo OR source /path/to/foo
                  This will run the process WITHIN the current bash instance.

                  exec /path/to/foo
                  This will REPLACE the current process with a new one.

                  It would help if Werner gave a little info on what he is trying
                  to do. Why does script2 need to be executed twice? Why can't you
                  just do the "stuff" IN script2 twice, etc.

                  If you want script1 to source script2 twice without running a new bash
                  instance, they just use the . operator to source it within the current
                  bash.

                  #!/bin/bash
                  . /path/to/script2
                  . /path/to/script2

                  If you want to have script1 source script2 the first time and then have
                  script2 REPLACE script1 the for the second run.

                  #!/bin/bash
                  . /path/to/script2
                  exec /path/to/script2

                  Jim Drabb
                  --
                  ----------------------------------------------------------
                  The box said: "Requires Windows 98/2000/XP/NT, or better."
                  So, I installed LINUX!
                  ----------------------------------------------------------
                  James Drabb JR
                  Senior Programmer Analyst
                  Darden Restaurants
                  Business Systems
                  JDrabb at Darden dot com
                • sigma957
                  I ve got an old pent 75 with 16megs of RAM and a 1.7G HD. I d like to install linux on (CLUI only)....I tried to install from the RH 9 CD, but it hangs after
                  Message 8 of 12 , Sep 4, 2003
                  • 0 Attachment
                    I've got an old pent 75 with 16megs of RAM and a 1.7G HD. I'd like to
                    install linux on (CLUI only)....I tried to install from the RH 9 CD, but it
                    hangs after detecting the cd drive on bootup (let it sit for 4 hours). Can
                    I install it with a boot diskette of some kind, or do I need to go with an
                    older version of RH?

                    If I need to go with an older version of RH, where can I find an iso image ?

                    Thanks,

                    Ripstop
                  • Werner vd Merwe
                    Hi, Basically what we need to do is the following: We start different SMS engines using the same command line, but with a different context path. Because of a
                    Message 9 of 12 , Sep 5, 2003
                    • 0 Attachment
                      Hi,

                      Basically what we need to do is the following:

                      We start different SMS engines using the same command line, but with a
                      different context path.
                      Because of a current instability with the implementation, we need to restart
                      this sms gateway script every 5 min.
                      But, if we do a ps, we need to have it display a different name for each
                      one, else it just reports it as 'java'

                      So we need to run script 1 to call script 2, so if we do a ps, we can see a
                      different script 1 for each gateway we start (3 in total ATM)

                      Does that make more sense?

                      Thx very much!


                      -----Original Message-----
                      From: James Drabb [mailto:JDrabb@...]
                      Sent: 04 September 2003 08:13 PM
                      To: RedHat
                      Subject: Re: [redhat] Scripts

                      On Thu, 2003-09-04 at 10:36, Scott Robbins wrote:
                      > On Thu, Sep 04, 2003 at 02:25:26PM +0200, Werner vd Merwe wrote:
                      > > A function of script1?
                      > >
                      > > My knowledge of scripting is next to zero :-)
                      >
                      > Yeah, so is mine. But it would work (in ksh, not sure if it's different
                      > in bash
                      >
                      > in script1
                      >
                      > SCRIPT2() {
                      > script2
                      > }
                      >
                      > Then, you can call the function in script1 by
                      > SCRIPT2
                      >
                      > (In bash, you might have to do it as
                      >
                      > function SCRIPT2()
                      >
                      > But I'm not sure. )
                      >
                      > However, definitely listen to James over me. :)

                      There are basically three ways to run another process.

                      /path/to/foo
                      This will run the process with ANOTHER bash instance. The new process
                      will not have the same environment variables as the current process.

                      . /path/to/foo OR source /path/to/foo
                      This will run the process WITHIN the current bash instance.

                      exec /path/to/foo
                      This will REPLACE the current process with a new one.

                      It would help if Werner gave a little info on what he is trying
                      to do. Why does script2 need to be executed twice? Why can't you
                      just do the "stuff" IN script2 twice, etc.

                      If you want script1 to source script2 twice without running a new bash
                      instance, they just use the . operator to source it within the current
                      bash.

                      #!/bin/bash
                      . /path/to/script2
                      . /path/to/script2

                      If you want to have script1 source script2 the first time and then have
                      script2 REPLACE script1 the for the second run.

                      #!/bin/bash
                      . /path/to/script2
                      exec /path/to/script2

                      Jim Drabb
                      --
                      ----------------------------------------------------------
                      The box said: "Requires Windows 98/2000/XP/NT, or better."
                      So, I installed LINUX!
                      ----------------------------------------------------------
                      James Drabb JR
                      Senior Programmer Analyst
                      Darden Restaurants
                      Business Systems
                      JDrabb at Darden dot com



                      Yahoo! Groups Sponsor
                      ADVERTISEMENT
                      click here
                      <http://rd.yahoo.com/M=259538.3830715.5078802.1261774/D=egroupweb/S=17050065
                      80:HM/A=1712983/R=0/SIG=11u38u3s2/*http://hits.411web.com/cgi-bin/hit?page=1
                      374-105951838331032>


                      To unsubscribe, email to redhat-unsubscribe@yahoogroups.com
                      To post to the redhat group, send your post to redhat@yahoogroups.com
                      To reach the moderators, email to redhat-owner@yahoogroups.com


                      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
                      <http://docs.yahoo.com/info/terms/> .


                      [Non-text portions of this message have been removed]
                    • John Smith
                      ... I m not sure that I ve correctly understood all the issues here, but here are three suggestions that may or may not be of use: 1. Write script1 to call
                      Message 10 of 12 , Sep 5, 2003
                      • 0 Attachment
                        Werner vd Merwe wrote:

                        >Hi,
                        >
                        >Basically what we need to do is the following:
                        >
                        >We start different SMS engines using the same command line, but with a
                        >different context path.
                        >Because of a current instability with the implementation, we need to restart
                        >this sms gateway script every 5 min.
                        >But, if we do a ps, we need to have it display a different name for each
                        >one, else it just reports it as 'java'
                        >
                        >So we need to run script 1 to call script 2, so if we do a ps, we can see a
                        >different script 1 for each gateway we start (3 in total ATM)
                        >
                        >Does that make more sense?
                        >
                        >Thx very much!
                        >
                        >
                        >
                        I'm not sure that I've correctly understood all the issues here, but
                        here are three suggestions that may or may not be of use:

                        1. Write script1 to call script2 in an infinite loop. For example

                        #!/bin/bash
                        while /bin/true
                        do
                        script2
                        sleep 300
                        done

                        2. Call script2 from a cron entry. The following entry would call
                        script2 every 5 minutes:

                        0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script2

                        or, slightly more elegantly:

                        */5 * * * * /path/to/script2

                        Something to note here is that script2 would be called at exactly 5
                        minute intervals, regardless of how long it took to execute. (In the
                        previous example, if script2 took one minute to execute, then it would
                        be called every 6 minutes.) This would raise issues if script2 took an
                        abnormally long amount of time to run (e.g. if a process could not be
                        killed).

                        3. On the point about seeing a different script under ps, you could use
                        links (hard or soft) to allow the same script to be called multiple
                        times, but to show up in different identifiable ways under ps. For example:

                        [john@oslo test]$ cat > slptst
                        #!/bin/bash
                        sleep 600
                        [john@oslo test]$ chmod 755 slptst
                        [john@oslo test]$ ln -s slptst slpsoftlink
                        [john@oslo test]$ ln slptst slphardlink
                        [john@oslo test]$ slptst &
                        [2] 7040
                        [john@oslo test]$ slpsoftlink &
                        [3] 7042
                        [john@oslo test]$ slphardlink &
                        [4] 7044
                        [john@oslo test]$ ps -ef | grep slp
                        john 7040 6783 0 13:34 pts/5 00:00:00 /bin/bash ./slptst
                        john 7042 6783 0 13:34 pts/5 00:00:00 /bin/bash ./slpsoftlink
                        john 7044 6783 0 13:35 pts/5 00:00:00 /bin/bash ./slphardlink
                        john 7047 6783 0 13:35 pts/5 00:00:00 grep slp
                        Here we have three processes, all ultimately running the same script,
                        but each one shows up as a different name. (I'm not sure exactly what
                        you mean when you said you used "the same command line, but with a
                        different context path" - do you have multiple copies of the same script
                        in different directories?)


                        Hope this is of some help.

                        Regards,

                        John
                      • James Drabb
                        ... Red Hat 7.3: http://www.linuxiso.org/distro.php?distro=7 There are also things such as Tiny Linux http://tiny.seul.org/en/. Jim Drabb -- ... The box said:
                        Message 11 of 12 , Sep 5, 2003
                        • 0 Attachment
                          On Thu, 2003-09-04 at 22:22, sigma957 wrote:
                          > I've got an old pent 75 with 16megs of RAM and a 1.7G HD. I'd like to
                          > install linux on (CLUI only)....I tried to install from the RH 9 CD, but it
                          > hangs after detecting the cd drive on bootup (let it sit for 4 hours). Can
                          > I install it with a boot diskette of some kind, or do I need to go with an
                          > older version of RH?
                          >
                          > If I need to go with an older version of RH, where can I find an iso image ?
                          >
                          > Thanks,
                          >
                          > Ripstop

                          Red Hat 7.3:
                          http://www.linuxiso.org/distro.php?distro=7

                          There are also things such as Tiny Linux http://tiny.seul.org/en/.

                          Jim Drabb
                          --
                          ----------------------------------------------------------
                          The box said: "Requires Windows 98/2000/XP/NT, or better."
                          So, I installed LINUX!
                          ----------------------------------------------------------
                          James Drabb JR
                          Senior Programmer Analyst
                          Davenport, FL USA
                          gpg --keyserver pgp.mit.edu --recv-keys 8C4CF29E
                        Your message has been successfully submitted and would be delivered to recipients shortly.