command not found via shell script but works on terminal

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












9














In my .sh file I cannot invoke ant or mv or cp commands but the same commands executes on terminal.below is my script



sample.sh file



#! /bin/sh
cp filename.so filename_org.so
android update project -p .
ant clean
ant release


path added in .bashrc file.



export PATH=$PATH:/usr/bin/


cp, mv , ant are working only under terminal not via scirpt.










share|improve this question



















  • 1




    Give us more info about yur problem..
    – Ruban Savvy
    Oct 20 '14 at 10:47










  • android / ant, are these binaries in /usr/bin?
    – UVV
    Oct 20 '14 at 11:38
















9














In my .sh file I cannot invoke ant or mv or cp commands but the same commands executes on terminal.below is my script



sample.sh file



#! /bin/sh
cp filename.so filename_org.so
android update project -p .
ant clean
ant release


path added in .bashrc file.



export PATH=$PATH:/usr/bin/


cp, mv , ant are working only under terminal not via scirpt.










share|improve this question



















  • 1




    Give us more info about yur problem..
    – Ruban Savvy
    Oct 20 '14 at 10:47










  • android / ant, are these binaries in /usr/bin?
    – UVV
    Oct 20 '14 at 11:38














9












9








9


1





In my .sh file I cannot invoke ant or mv or cp commands but the same commands executes on terminal.below is my script



sample.sh file



#! /bin/sh
cp filename.so filename_org.so
android update project -p .
ant clean
ant release


path added in .bashrc file.



export PATH=$PATH:/usr/bin/


cp, mv , ant are working only under terminal not via scirpt.










share|improve this question















In my .sh file I cannot invoke ant or mv or cp commands but the same commands executes on terminal.below is my script



sample.sh file



#! /bin/sh
cp filename.so filename_org.so
android update project -p .
ant clean
ant release


path added in .bashrc file.



export PATH=$PATH:/usr/bin/


cp, mv , ant are working only under terminal not via scirpt.







shell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 20 '14 at 11:14

























asked Oct 20 '14 at 10:39









user755

148114




148114







  • 1




    Give us more info about yur problem..
    – Ruban Savvy
    Oct 20 '14 at 10:47










  • android / ant, are these binaries in /usr/bin?
    – UVV
    Oct 20 '14 at 11:38













  • 1




    Give us more info about yur problem..
    – Ruban Savvy
    Oct 20 '14 at 10:47










  • android / ant, are these binaries in /usr/bin?
    – UVV
    Oct 20 '14 at 11:38








1




1




Give us more info about yur problem..
– Ruban Savvy
Oct 20 '14 at 10:47




Give us more info about yur problem..
– Ruban Savvy
Oct 20 '14 at 10:47












android / ant, are these binaries in /usr/bin?
– UVV
Oct 20 '14 at 11:38





android / ant, are these binaries in /usr/bin?
– UVV
Oct 20 '14 at 11:38











2 Answers
2






active

oldest

votes


















7














As your script is a shell script (/bin/sh), then your PATH entries in .bashrc will not be read as that is for the bash (/bin/bash) interactive shell.



To make your PATH entries available to /bin/sh scripts run by a specific user, add the PATH entry to the .profile file in that users home directory.




Additionally you could add the full path for each of your commands within the script:



/bin/cp filename.so filename_org.so


Or set the PATH variable including all the required $PATHS at the beginning of your script.



PATH=$PATH:/bin:/usr/bin:xxx
export PATH





share|improve this answer


















  • 2




    Correct analysis, but you didn't mention the right solution, which is to set PATH in the proper place instead of .bashrc. Changing the script to be a bash script will not make any difference: .bashrc is only loaded by interactive shells.
    – Gilles
    Oct 21 '14 at 21:34


















0














Had the same issue while running a binary whose path is set in bashrc.



Solved the issue by doing the following:



Add the binary or add a link to the binary in /usr/bin.



ln -s [path_to_binary] [name_of_executable] 


Then check using



ls -l


You can remove the entry form bashrc.






share|improve this answer




















    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    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%2f163120%2fcommand-not-found-via-shell-script-but-works-on-terminal%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    As your script is a shell script (/bin/sh), then your PATH entries in .bashrc will not be read as that is for the bash (/bin/bash) interactive shell.



    To make your PATH entries available to /bin/sh scripts run by a specific user, add the PATH entry to the .profile file in that users home directory.




    Additionally you could add the full path for each of your commands within the script:



    /bin/cp filename.so filename_org.so


    Or set the PATH variable including all the required $PATHS at the beginning of your script.



    PATH=$PATH:/bin:/usr/bin:xxx
    export PATH





    share|improve this answer


















    • 2




      Correct analysis, but you didn't mention the right solution, which is to set PATH in the proper place instead of .bashrc. Changing the script to be a bash script will not make any difference: .bashrc is only loaded by interactive shells.
      – Gilles
      Oct 21 '14 at 21:34















    7














    As your script is a shell script (/bin/sh), then your PATH entries in .bashrc will not be read as that is for the bash (/bin/bash) interactive shell.



    To make your PATH entries available to /bin/sh scripts run by a specific user, add the PATH entry to the .profile file in that users home directory.




    Additionally you could add the full path for each of your commands within the script:



    /bin/cp filename.so filename_org.so


    Or set the PATH variable including all the required $PATHS at the beginning of your script.



    PATH=$PATH:/bin:/usr/bin:xxx
    export PATH





    share|improve this answer


















    • 2




      Correct analysis, but you didn't mention the right solution, which is to set PATH in the proper place instead of .bashrc. Changing the script to be a bash script will not make any difference: .bashrc is only loaded by interactive shells.
      – Gilles
      Oct 21 '14 at 21:34













    7












    7








    7






    As your script is a shell script (/bin/sh), then your PATH entries in .bashrc will not be read as that is for the bash (/bin/bash) interactive shell.



    To make your PATH entries available to /bin/sh scripts run by a specific user, add the PATH entry to the .profile file in that users home directory.




    Additionally you could add the full path for each of your commands within the script:



    /bin/cp filename.so filename_org.so


    Or set the PATH variable including all the required $PATHS at the beginning of your script.



    PATH=$PATH:/bin:/usr/bin:xxx
    export PATH





    share|improve this answer














    As your script is a shell script (/bin/sh), then your PATH entries in .bashrc will not be read as that is for the bash (/bin/bash) interactive shell.



    To make your PATH entries available to /bin/sh scripts run by a specific user, add the PATH entry to the .profile file in that users home directory.




    Additionally you could add the full path for each of your commands within the script:



    /bin/cp filename.so filename_org.so


    Or set the PATH variable including all the required $PATHS at the beginning of your script.



    PATH=$PATH:/bin:/usr/bin:xxx
    export PATH






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 21 '14 at 23:00

























    answered Oct 20 '14 at 11:41









    geedoubleya

    3,0131118




    3,0131118







    • 2




      Correct analysis, but you didn't mention the right solution, which is to set PATH in the proper place instead of .bashrc. Changing the script to be a bash script will not make any difference: .bashrc is only loaded by interactive shells.
      – Gilles
      Oct 21 '14 at 21:34












    • 2




      Correct analysis, but you didn't mention the right solution, which is to set PATH in the proper place instead of .bashrc. Changing the script to be a bash script will not make any difference: .bashrc is only loaded by interactive shells.
      – Gilles
      Oct 21 '14 at 21:34







    2




    2




    Correct analysis, but you didn't mention the right solution, which is to set PATH in the proper place instead of .bashrc. Changing the script to be a bash script will not make any difference: .bashrc is only loaded by interactive shells.
    – Gilles
    Oct 21 '14 at 21:34




    Correct analysis, but you didn't mention the right solution, which is to set PATH in the proper place instead of .bashrc. Changing the script to be a bash script will not make any difference: .bashrc is only loaded by interactive shells.
    – Gilles
    Oct 21 '14 at 21:34













    0














    Had the same issue while running a binary whose path is set in bashrc.



    Solved the issue by doing the following:



    Add the binary or add a link to the binary in /usr/bin.



    ln -s [path_to_binary] [name_of_executable] 


    Then check using



    ls -l


    You can remove the entry form bashrc.






    share|improve this answer

























      0














      Had the same issue while running a binary whose path is set in bashrc.



      Solved the issue by doing the following:



      Add the binary or add a link to the binary in /usr/bin.



      ln -s [path_to_binary] [name_of_executable] 


      Then check using



      ls -l


      You can remove the entry form bashrc.






      share|improve this answer























        0












        0








        0






        Had the same issue while running a binary whose path is set in bashrc.



        Solved the issue by doing the following:



        Add the binary or add a link to the binary in /usr/bin.



        ln -s [path_to_binary] [name_of_executable] 


        Then check using



        ls -l


        You can remove the entry form bashrc.






        share|improve this answer












        Had the same issue while running a binary whose path is set in bashrc.



        Solved the issue by doing the following:



        Add the binary or add a link to the binary in /usr/bin.



        ln -s [path_to_binary] [name_of_executable] 


        Then check using



        ls -l


        You can remove the entry form bashrc.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 10 '17 at 6:57









        Naba

        1




        1



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f163120%2fcommand-not-found-via-shell-script-but-works-on-terminal%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            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?