Automate a process using bash script

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











up vote
0
down vote

favorite












I have a unimrcp client process (ucp) and I want to spawn multiple ucp using shell script.



Whenever I spawn a ucp, it returns a command line using which I can access different functionalities in ucp. So I want to write a script that achieves following,



  1. Spawn a ucp process

  2. wait until the ucp's command line appears

  3. access ucp's functionality with a command "run recog"

Note that ./ucp && run recog does not work since ./ucp is finished only after we exit from the command line of ucp.



I tried the following for this,



#!/bin/bash 
./ucp &
fg
echo "run recog uni2"
wait


However, ./ucp & results into starting the client process and then writing "?????" on the client console resulting into "????" command not found. Following are the logs,



./script.sh

2018-10-23 14:36:53:618851 [INFO] Set Property ip:127.0.0.1
2018-10-23 14:36:53:618851 [INFO] Register Codec [PCMU]
2018-10-23 14:36:53:618851 [INFO] Register Codec [PCMA]
2018-10-23 14:36:53:618851 [INFO] Register Codec [L16]
2018-10-23 14:36:53:618851 [NOTICE] Register Resource [speechsynth]
2018-10-23 14:36:53:618851 [NOTICE] Register Resource [speechrecog]
2018-10-23 14:36:53:620588 [NOTICE] Register Resource [recorder]
2018-10-23 14:36:53:620588 [NOTICE] Register Resource [speakverify]
2018-10-23 14:36:53:620593 [INFO] Register Resource Factory
2018-10-23 14:36:53:620600 [NOTICE] Create SofiaSIP Agent [SIP-Agent-1] [1.12.11-227-g73efc97] sip:127.0.0.1:8062;transport=udp
2018-10-23 14:36:53:620600 [INFO] Register Signaling Agent [SIP-Agent-1]
2018-10-23 14:36:53:620600 [NOTICE] Create RTSP Client [RTSP-Agent-1] [100]
2018-10-23 14:36:53:620600 [INFO] Register Signaling Agent [RTSP-Agent-1]
2018-10-23 14:36:53:620600 [NOTICE] Create MRCPv2 Agent [MRCPv2-Agent-1] [100]
2018-10-23 14:36:53:620600 [INFO] Register Connection Agent [MRCPv2-Agent-1]
2018-10-23 14:36:53:620600 [NOTICE] Create Media Engine [Media-Engine-1]
unknown command: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????


Is this the right way to achieve what I mentioned in the question? (spawn a client and run a command on its console)? If yes, why does the "./ucp &" results in reading "?????" considering that as input to its console? Note that this does not happen if I simply fire "./ucp & fg " from the console. It can see the expected behavior of the command when I do it from the console. The issue appears when I try to execute the script.



If this is not a right way, How can I achieve what I mentioned in the question? (1, 2, and 3)



Thank you










share|improve this question







New contributor




sbhatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    0
    down vote

    favorite












    I have a unimrcp client process (ucp) and I want to spawn multiple ucp using shell script.



    Whenever I spawn a ucp, it returns a command line using which I can access different functionalities in ucp. So I want to write a script that achieves following,



    1. Spawn a ucp process

    2. wait until the ucp's command line appears

    3. access ucp's functionality with a command "run recog"

    Note that ./ucp && run recog does not work since ./ucp is finished only after we exit from the command line of ucp.



    I tried the following for this,



    #!/bin/bash 
    ./ucp &
    fg
    echo "run recog uni2"
    wait


    However, ./ucp & results into starting the client process and then writing "?????" on the client console resulting into "????" command not found. Following are the logs,



    ./script.sh

    2018-10-23 14:36:53:618851 [INFO] Set Property ip:127.0.0.1
    2018-10-23 14:36:53:618851 [INFO] Register Codec [PCMU]
    2018-10-23 14:36:53:618851 [INFO] Register Codec [PCMA]
    2018-10-23 14:36:53:618851 [INFO] Register Codec [L16]
    2018-10-23 14:36:53:618851 [NOTICE] Register Resource [speechsynth]
    2018-10-23 14:36:53:618851 [NOTICE] Register Resource [speechrecog]
    2018-10-23 14:36:53:620588 [NOTICE] Register Resource [recorder]
    2018-10-23 14:36:53:620588 [NOTICE] Register Resource [speakverify]
    2018-10-23 14:36:53:620593 [INFO] Register Resource Factory
    2018-10-23 14:36:53:620600 [NOTICE] Create SofiaSIP Agent [SIP-Agent-1] [1.12.11-227-g73efc97] sip:127.0.0.1:8062;transport=udp
    2018-10-23 14:36:53:620600 [INFO] Register Signaling Agent [SIP-Agent-1]
    2018-10-23 14:36:53:620600 [NOTICE] Create RTSP Client [RTSP-Agent-1] [100]
    2018-10-23 14:36:53:620600 [INFO] Register Signaling Agent [RTSP-Agent-1]
    2018-10-23 14:36:53:620600 [NOTICE] Create MRCPv2 Agent [MRCPv2-Agent-1] [100]
    2018-10-23 14:36:53:620600 [INFO] Register Connection Agent [MRCPv2-Agent-1]
    2018-10-23 14:36:53:620600 [NOTICE] Create Media Engine [Media-Engine-1]
    unknown command: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????


    Is this the right way to achieve what I mentioned in the question? (spawn a client and run a command on its console)? If yes, why does the "./ucp &" results in reading "?????" considering that as input to its console? Note that this does not happen if I simply fire "./ucp & fg " from the console. It can see the expected behavior of the command when I do it from the console. The issue appears when I try to execute the script.



    If this is not a right way, How can I achieve what I mentioned in the question? (1, 2, and 3)



    Thank you










    share|improve this question







    New contributor




    sbhatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a unimrcp client process (ucp) and I want to spawn multiple ucp using shell script.



      Whenever I spawn a ucp, it returns a command line using which I can access different functionalities in ucp. So I want to write a script that achieves following,



      1. Spawn a ucp process

      2. wait until the ucp's command line appears

      3. access ucp's functionality with a command "run recog"

      Note that ./ucp && run recog does not work since ./ucp is finished only after we exit from the command line of ucp.



      I tried the following for this,



      #!/bin/bash 
      ./ucp &
      fg
      echo "run recog uni2"
      wait


      However, ./ucp & results into starting the client process and then writing "?????" on the client console resulting into "????" command not found. Following are the logs,



      ./script.sh

      2018-10-23 14:36:53:618851 [INFO] Set Property ip:127.0.0.1
      2018-10-23 14:36:53:618851 [INFO] Register Codec [PCMU]
      2018-10-23 14:36:53:618851 [INFO] Register Codec [PCMA]
      2018-10-23 14:36:53:618851 [INFO] Register Codec [L16]
      2018-10-23 14:36:53:618851 [NOTICE] Register Resource [speechsynth]
      2018-10-23 14:36:53:618851 [NOTICE] Register Resource [speechrecog]
      2018-10-23 14:36:53:620588 [NOTICE] Register Resource [recorder]
      2018-10-23 14:36:53:620588 [NOTICE] Register Resource [speakverify]
      2018-10-23 14:36:53:620593 [INFO] Register Resource Factory
      2018-10-23 14:36:53:620600 [NOTICE] Create SofiaSIP Agent [SIP-Agent-1] [1.12.11-227-g73efc97] sip:127.0.0.1:8062;transport=udp
      2018-10-23 14:36:53:620600 [INFO] Register Signaling Agent [SIP-Agent-1]
      2018-10-23 14:36:53:620600 [NOTICE] Create RTSP Client [RTSP-Agent-1] [100]
      2018-10-23 14:36:53:620600 [INFO] Register Signaling Agent [RTSP-Agent-1]
      2018-10-23 14:36:53:620600 [NOTICE] Create MRCPv2 Agent [MRCPv2-Agent-1] [100]
      2018-10-23 14:36:53:620600 [INFO] Register Connection Agent [MRCPv2-Agent-1]
      2018-10-23 14:36:53:620600 [NOTICE] Create Media Engine [Media-Engine-1]
      unknown command: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????


      Is this the right way to achieve what I mentioned in the question? (spawn a client and run a command on its console)? If yes, why does the "./ucp &" results in reading "?????" considering that as input to its console? Note that this does not happen if I simply fire "./ucp & fg " from the console. It can see the expected behavior of the command when I do it from the console. The issue appears when I try to execute the script.



      If this is not a right way, How can I achieve what I mentioned in the question? (1, 2, and 3)



      Thank you










      share|improve this question







      New contributor




      sbhatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have a unimrcp client process (ucp) and I want to spawn multiple ucp using shell script.



      Whenever I spawn a ucp, it returns a command line using which I can access different functionalities in ucp. So I want to write a script that achieves following,



      1. Spawn a ucp process

      2. wait until the ucp's command line appears

      3. access ucp's functionality with a command "run recog"

      Note that ./ucp && run recog does not work since ./ucp is finished only after we exit from the command line of ucp.



      I tried the following for this,



      #!/bin/bash 
      ./ucp &
      fg
      echo "run recog uni2"
      wait


      However, ./ucp & results into starting the client process and then writing "?????" on the client console resulting into "????" command not found. Following are the logs,



      ./script.sh

      2018-10-23 14:36:53:618851 [INFO] Set Property ip:127.0.0.1
      2018-10-23 14:36:53:618851 [INFO] Register Codec [PCMU]
      2018-10-23 14:36:53:618851 [INFO] Register Codec [PCMA]
      2018-10-23 14:36:53:618851 [INFO] Register Codec [L16]
      2018-10-23 14:36:53:618851 [NOTICE] Register Resource [speechsynth]
      2018-10-23 14:36:53:618851 [NOTICE] Register Resource [speechrecog]
      2018-10-23 14:36:53:620588 [NOTICE] Register Resource [recorder]
      2018-10-23 14:36:53:620588 [NOTICE] Register Resource [speakverify]
      2018-10-23 14:36:53:620593 [INFO] Register Resource Factory
      2018-10-23 14:36:53:620600 [NOTICE] Create SofiaSIP Agent [SIP-Agent-1] [1.12.11-227-g73efc97] sip:127.0.0.1:8062;transport=udp
      2018-10-23 14:36:53:620600 [INFO] Register Signaling Agent [SIP-Agent-1]
      2018-10-23 14:36:53:620600 [NOTICE] Create RTSP Client [RTSP-Agent-1] [100]
      2018-10-23 14:36:53:620600 [INFO] Register Signaling Agent [RTSP-Agent-1]
      2018-10-23 14:36:53:620600 [NOTICE] Create MRCPv2 Agent [MRCPv2-Agent-1] [100]
      2018-10-23 14:36:53:620600 [INFO] Register Connection Agent [MRCPv2-Agent-1]
      2018-10-23 14:36:53:620600 [NOTICE] Create Media Engine [Media-Engine-1]
      unknown command: ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????


      Is this the right way to achieve what I mentioned in the question? (spawn a client and run a command on its console)? If yes, why does the "./ucp &" results in reading "?????" considering that as input to its console? Note that this does not happen if I simply fire "./ucp & fg " from the console. It can see the expected behavior of the command when I do it from the console. The issue appears when I try to execute the script.



      If this is not a right way, How can I achieve what I mentioned in the question? (1, 2, and 3)



      Thank you







      linux shell-script process






      share|improve this question







      New contributor




      sbhatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      sbhatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      sbhatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 17 mins ago









      sbhatt

      101




      101




      New contributor




      sbhatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      sbhatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      sbhatt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

























          active

          oldest

          votes











          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
          );



          );






          sbhatt is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477612%2fautomate-a-process-using-bash-script%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          sbhatt is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          sbhatt is a new contributor. Be nice, and check out our Code of Conduct.












          sbhatt is a new contributor. Be nice, and check out our Code of Conduct.











          sbhatt is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477612%2fautomate-a-process-using-bash-script%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?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?