Using script command for installation script on AIX

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I have an installation script for my software and I need it to run on both, Linux and AIX.



On Linux I can use a wrapper myinstaller.ksh like this one:



#!/usr/bin/ksh
script -c myrealinstaller.ksh /var/log/myinstaller.log


But on AIX script does not support the -c option.



How can I run my myrealinstaller.ksh inside the forked shell created by script?







share|improve this question


























    up vote
    3
    down vote

    favorite












    I have an installation script for my software and I need it to run on both, Linux and AIX.



    On Linux I can use a wrapper myinstaller.ksh like this one:



    #!/usr/bin/ksh
    script -c myrealinstaller.ksh /var/log/myinstaller.log


    But on AIX script does not support the -c option.



    How can I run my myrealinstaller.ksh inside the forked shell created by script?







    share|improve this question
























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I have an installation script for my software and I need it to run on both, Linux and AIX.



      On Linux I can use a wrapper myinstaller.ksh like this one:



      #!/usr/bin/ksh
      script -c myrealinstaller.ksh /var/log/myinstaller.log


      But on AIX script does not support the -c option.



      How can I run my myrealinstaller.ksh inside the forked shell created by script?







      share|improve this question














      I have an installation script for my software and I need it to run on both, Linux and AIX.



      On Linux I can use a wrapper myinstaller.ksh like this one:



      #!/usr/bin/ksh
      script -c myrealinstaller.ksh /var/log/myinstaller.log


      But on AIX script does not support the -c option.



      How can I run my myrealinstaller.ksh inside the forked shell created by script?









      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 15 at 13:09









      Stephen Kitt

      141k22307367




      141k22307367










      asked Mar 15 at 12:45









      Patrick

      898




      898




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You could enhance your wrapper script to detect the OS; if it's running on Linux, execute script -c ..., but if it's running on AIX, give the script-shell an overridden profile that only runs your installer, then exits:



          $ cat myinstaller.ksh
          #!/usr/bin/ksh

          case $(uname -s) in
          (Linux)
          script -c myrealinstaller.ksh /var/log/myinstaller.log
          ;;
          (AIX)
          printf "ENV= ./myrealinstaller.kshnexitn" > ./installer.profile
          trap 'rm -f ./installer.profile' INT
          ENV=./installer.profile script -q ./var/log/myinstaller.log
          rm ./installer.profile
          ;;
          esac


          I adjusted the paths to the script and logs to test it locally. The other factors involved are:



          • setting ENV to point to the overridden profile as we call script

          • calling script with -q to quiet it down a bit

          • importantly, unsetting ENV during the call to the real installer, so that we don't loop infinitely

          • telling the overridden profile to exit as soon as the installer is done

          With a sample myrealinstaller.ksh of:



          #!/bin/ksh
          echo Hi, I am the real installer


          The contents of ./var/log/myinstaller.log are:



          Script command is started on Thu Mar 15 09:34:04 2018.
          Hi, I am the real installer


          Script command is complete on Thu Mar 15 09:34:04 2018.





          share|improve this answer






















          • Nice, this works very well. The only problem I found is the installer.profile which is not removed if the real installer is interrupted by ctrl+c.
            – Patrick
            Mar 15 at 15:05










          • Glad to hear that it works, @P.Jksch! I've added a line to remove the installer.profile intermediate file if the user hits Control-C.
            – Jeff Schaller
            Mar 15 at 15:20











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430389%2fusing-script-command-for-installation-script-on-aix%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          You could enhance your wrapper script to detect the OS; if it's running on Linux, execute script -c ..., but if it's running on AIX, give the script-shell an overridden profile that only runs your installer, then exits:



          $ cat myinstaller.ksh
          #!/usr/bin/ksh

          case $(uname -s) in
          (Linux)
          script -c myrealinstaller.ksh /var/log/myinstaller.log
          ;;
          (AIX)
          printf "ENV= ./myrealinstaller.kshnexitn" > ./installer.profile
          trap 'rm -f ./installer.profile' INT
          ENV=./installer.profile script -q ./var/log/myinstaller.log
          rm ./installer.profile
          ;;
          esac


          I adjusted the paths to the script and logs to test it locally. The other factors involved are:



          • setting ENV to point to the overridden profile as we call script

          • calling script with -q to quiet it down a bit

          • importantly, unsetting ENV during the call to the real installer, so that we don't loop infinitely

          • telling the overridden profile to exit as soon as the installer is done

          With a sample myrealinstaller.ksh of:



          #!/bin/ksh
          echo Hi, I am the real installer


          The contents of ./var/log/myinstaller.log are:



          Script command is started on Thu Mar 15 09:34:04 2018.
          Hi, I am the real installer


          Script command is complete on Thu Mar 15 09:34:04 2018.





          share|improve this answer






















          • Nice, this works very well. The only problem I found is the installer.profile which is not removed if the real installer is interrupted by ctrl+c.
            – Patrick
            Mar 15 at 15:05










          • Glad to hear that it works, @P.Jksch! I've added a line to remove the installer.profile intermediate file if the user hits Control-C.
            – Jeff Schaller
            Mar 15 at 15:20















          up vote
          1
          down vote



          accepted










          You could enhance your wrapper script to detect the OS; if it's running on Linux, execute script -c ..., but if it's running on AIX, give the script-shell an overridden profile that only runs your installer, then exits:



          $ cat myinstaller.ksh
          #!/usr/bin/ksh

          case $(uname -s) in
          (Linux)
          script -c myrealinstaller.ksh /var/log/myinstaller.log
          ;;
          (AIX)
          printf "ENV= ./myrealinstaller.kshnexitn" > ./installer.profile
          trap 'rm -f ./installer.profile' INT
          ENV=./installer.profile script -q ./var/log/myinstaller.log
          rm ./installer.profile
          ;;
          esac


          I adjusted the paths to the script and logs to test it locally. The other factors involved are:



          • setting ENV to point to the overridden profile as we call script

          • calling script with -q to quiet it down a bit

          • importantly, unsetting ENV during the call to the real installer, so that we don't loop infinitely

          • telling the overridden profile to exit as soon as the installer is done

          With a sample myrealinstaller.ksh of:



          #!/bin/ksh
          echo Hi, I am the real installer


          The contents of ./var/log/myinstaller.log are:



          Script command is started on Thu Mar 15 09:34:04 2018.
          Hi, I am the real installer


          Script command is complete on Thu Mar 15 09:34:04 2018.





          share|improve this answer






















          • Nice, this works very well. The only problem I found is the installer.profile which is not removed if the real installer is interrupted by ctrl+c.
            – Patrick
            Mar 15 at 15:05










          • Glad to hear that it works, @P.Jksch! I've added a line to remove the installer.profile intermediate file if the user hits Control-C.
            – Jeff Schaller
            Mar 15 at 15:20













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          You could enhance your wrapper script to detect the OS; if it's running on Linux, execute script -c ..., but if it's running on AIX, give the script-shell an overridden profile that only runs your installer, then exits:



          $ cat myinstaller.ksh
          #!/usr/bin/ksh

          case $(uname -s) in
          (Linux)
          script -c myrealinstaller.ksh /var/log/myinstaller.log
          ;;
          (AIX)
          printf "ENV= ./myrealinstaller.kshnexitn" > ./installer.profile
          trap 'rm -f ./installer.profile' INT
          ENV=./installer.profile script -q ./var/log/myinstaller.log
          rm ./installer.profile
          ;;
          esac


          I adjusted the paths to the script and logs to test it locally. The other factors involved are:



          • setting ENV to point to the overridden profile as we call script

          • calling script with -q to quiet it down a bit

          • importantly, unsetting ENV during the call to the real installer, so that we don't loop infinitely

          • telling the overridden profile to exit as soon as the installer is done

          With a sample myrealinstaller.ksh of:



          #!/bin/ksh
          echo Hi, I am the real installer


          The contents of ./var/log/myinstaller.log are:



          Script command is started on Thu Mar 15 09:34:04 2018.
          Hi, I am the real installer


          Script command is complete on Thu Mar 15 09:34:04 2018.





          share|improve this answer














          You could enhance your wrapper script to detect the OS; if it's running on Linux, execute script -c ..., but if it's running on AIX, give the script-shell an overridden profile that only runs your installer, then exits:



          $ cat myinstaller.ksh
          #!/usr/bin/ksh

          case $(uname -s) in
          (Linux)
          script -c myrealinstaller.ksh /var/log/myinstaller.log
          ;;
          (AIX)
          printf "ENV= ./myrealinstaller.kshnexitn" > ./installer.profile
          trap 'rm -f ./installer.profile' INT
          ENV=./installer.profile script -q ./var/log/myinstaller.log
          rm ./installer.profile
          ;;
          esac


          I adjusted the paths to the script and logs to test it locally. The other factors involved are:



          • setting ENV to point to the overridden profile as we call script

          • calling script with -q to quiet it down a bit

          • importantly, unsetting ENV during the call to the real installer, so that we don't loop infinitely

          • telling the overridden profile to exit as soon as the installer is done

          With a sample myrealinstaller.ksh of:



          #!/bin/ksh
          echo Hi, I am the real installer


          The contents of ./var/log/myinstaller.log are:



          Script command is started on Thu Mar 15 09:34:04 2018.
          Hi, I am the real installer


          Script command is complete on Thu Mar 15 09:34:04 2018.






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 15 at 15:19

























          answered Mar 15 at 13:38









          Jeff Schaller

          31.2k846105




          31.2k846105











          • Nice, this works very well. The only problem I found is the installer.profile which is not removed if the real installer is interrupted by ctrl+c.
            – Patrick
            Mar 15 at 15:05










          • Glad to hear that it works, @P.Jksch! I've added a line to remove the installer.profile intermediate file if the user hits Control-C.
            – Jeff Schaller
            Mar 15 at 15:20

















          • Nice, this works very well. The only problem I found is the installer.profile which is not removed if the real installer is interrupted by ctrl+c.
            – Patrick
            Mar 15 at 15:05










          • Glad to hear that it works, @P.Jksch! I've added a line to remove the installer.profile intermediate file if the user hits Control-C.
            – Jeff Schaller
            Mar 15 at 15:20
















          Nice, this works very well. The only problem I found is the installer.profile which is not removed if the real installer is interrupted by ctrl+c.
          – Patrick
          Mar 15 at 15:05




          Nice, this works very well. The only problem I found is the installer.profile which is not removed if the real installer is interrupted by ctrl+c.
          – Patrick
          Mar 15 at 15:05












          Glad to hear that it works, @P.Jksch! I've added a line to remove the installer.profile intermediate file if the user hits Control-C.
          – Jeff Schaller
          Mar 15 at 15:20





          Glad to hear that it works, @P.Jksch! I've added a line to remove the installer.profile intermediate file if the user hits Control-C.
          – Jeff Schaller
          Mar 15 at 15:20













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430389%2fusing-script-command-for-installation-script-on-aix%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay