Changing permissions of the file, while using sftp command in a shell script

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











up vote
1
down vote

favorite












How can I change the permissions of the file/command, while using the sftp command via a shell script? My sftp connection is established, but it fails while executing the chmod command.



As of now, I am using chmod 775, which exits without creating proper permissions in the target directory.










share|improve this question























  • Is there any error message? what is the login used to connect ? what is the result of ls -l filename via sftp? what is the result and error message if you do it manually? Could you edit the Question and provide this information?
    – Jay jargot
    May 15 '16 at 21:13










  • You say that you're using sftp in the context of a shell script. How are you passing the commands to sftp? If you're using the -b switch, I cannot replicate your problem; I have successfully used it to upload a file and change its permissions.
    – DopeGhoti
    May 15 '16 at 21:14










  • 1) the only error message i receive is invalid command. the command, i pass through the script is quote site chmod 750 $file.txt, after the put command. The put is successful. When, i do it manually, i am not receiving any error. It is successful. Only when done via script it errors me out. there are 2 files i ftp and both are able to be sftp'ed.
    – Sravani
    May 16 '16 at 14:55










  • I am passing the commands via a script. I am not using the -b. I specified all the parameters in the script first and then pass the parameters in the command.The only commands i used in the script is sftp username@hostname put file1 put file 2 quote site chmod 775 file 1 quote site chmod 775 file 2 is there any other command i have to use, when i am doing the sftp and trying to do chmod.
    – Sravani
    May 16 '16 at 14:57











  • sftp username@hostname put file1 put file2 quote site chmod 750 $file1 quote site chmod 750 $file2 quit EOF
    – Sravani
    May 16 '16 at 15:01














up vote
1
down vote

favorite












How can I change the permissions of the file/command, while using the sftp command via a shell script? My sftp connection is established, but it fails while executing the chmod command.



As of now, I am using chmod 775, which exits without creating proper permissions in the target directory.










share|improve this question























  • Is there any error message? what is the login used to connect ? what is the result of ls -l filename via sftp? what is the result and error message if you do it manually? Could you edit the Question and provide this information?
    – Jay jargot
    May 15 '16 at 21:13










  • You say that you're using sftp in the context of a shell script. How are you passing the commands to sftp? If you're using the -b switch, I cannot replicate your problem; I have successfully used it to upload a file and change its permissions.
    – DopeGhoti
    May 15 '16 at 21:14










  • 1) the only error message i receive is invalid command. the command, i pass through the script is quote site chmod 750 $file.txt, after the put command. The put is successful. When, i do it manually, i am not receiving any error. It is successful. Only when done via script it errors me out. there are 2 files i ftp and both are able to be sftp'ed.
    – Sravani
    May 16 '16 at 14:55










  • I am passing the commands via a script. I am not using the -b. I specified all the parameters in the script first and then pass the parameters in the command.The only commands i used in the script is sftp username@hostname put file1 put file 2 quote site chmod 775 file 1 quote site chmod 775 file 2 is there any other command i have to use, when i am doing the sftp and trying to do chmod.
    – Sravani
    May 16 '16 at 14:57











  • sftp username@hostname put file1 put file2 quote site chmod 750 $file1 quote site chmod 750 $file2 quit EOF
    – Sravani
    May 16 '16 at 15:01












up vote
1
down vote

favorite









up vote
1
down vote

favorite











How can I change the permissions of the file/command, while using the sftp command via a shell script? My sftp connection is established, but it fails while executing the chmod command.



As of now, I am using chmod 775, which exits without creating proper permissions in the target directory.










share|improve this question















How can I change the permissions of the file/command, while using the sftp command via a shell script? My sftp connection is established, but it fails while executing the chmod command.



As of now, I am using chmod 775, which exits without creating proper permissions in the target directory.







shell-script chmod sftp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 15 '16 at 23:36









Jeff Schaller

32.7k849110




32.7k849110










asked May 15 '16 at 20:43









Sravani

612




612











  • Is there any error message? what is the login used to connect ? what is the result of ls -l filename via sftp? what is the result and error message if you do it manually? Could you edit the Question and provide this information?
    – Jay jargot
    May 15 '16 at 21:13










  • You say that you're using sftp in the context of a shell script. How are you passing the commands to sftp? If you're using the -b switch, I cannot replicate your problem; I have successfully used it to upload a file and change its permissions.
    – DopeGhoti
    May 15 '16 at 21:14










  • 1) the only error message i receive is invalid command. the command, i pass through the script is quote site chmod 750 $file.txt, after the put command. The put is successful. When, i do it manually, i am not receiving any error. It is successful. Only when done via script it errors me out. there are 2 files i ftp and both are able to be sftp'ed.
    – Sravani
    May 16 '16 at 14:55










  • I am passing the commands via a script. I am not using the -b. I specified all the parameters in the script first and then pass the parameters in the command.The only commands i used in the script is sftp username@hostname put file1 put file 2 quote site chmod 775 file 1 quote site chmod 775 file 2 is there any other command i have to use, when i am doing the sftp and trying to do chmod.
    – Sravani
    May 16 '16 at 14:57











  • sftp username@hostname put file1 put file2 quote site chmod 750 $file1 quote site chmod 750 $file2 quit EOF
    – Sravani
    May 16 '16 at 15:01
















  • Is there any error message? what is the login used to connect ? what is the result of ls -l filename via sftp? what is the result and error message if you do it manually? Could you edit the Question and provide this information?
    – Jay jargot
    May 15 '16 at 21:13










  • You say that you're using sftp in the context of a shell script. How are you passing the commands to sftp? If you're using the -b switch, I cannot replicate your problem; I have successfully used it to upload a file and change its permissions.
    – DopeGhoti
    May 15 '16 at 21:14










  • 1) the only error message i receive is invalid command. the command, i pass through the script is quote site chmod 750 $file.txt, after the put command. The put is successful. When, i do it manually, i am not receiving any error. It is successful. Only when done via script it errors me out. there are 2 files i ftp and both are able to be sftp'ed.
    – Sravani
    May 16 '16 at 14:55










  • I am passing the commands via a script. I am not using the -b. I specified all the parameters in the script first and then pass the parameters in the command.The only commands i used in the script is sftp username@hostname put file1 put file 2 quote site chmod 775 file 1 quote site chmod 775 file 2 is there any other command i have to use, when i am doing the sftp and trying to do chmod.
    – Sravani
    May 16 '16 at 14:57











  • sftp username@hostname put file1 put file2 quote site chmod 750 $file1 quote site chmod 750 $file2 quit EOF
    – Sravani
    May 16 '16 at 15:01















Is there any error message? what is the login used to connect ? what is the result of ls -l filename via sftp? what is the result and error message if you do it manually? Could you edit the Question and provide this information?
– Jay jargot
May 15 '16 at 21:13




Is there any error message? what is the login used to connect ? what is the result of ls -l filename via sftp? what is the result and error message if you do it manually? Could you edit the Question and provide this information?
– Jay jargot
May 15 '16 at 21:13












You say that you're using sftp in the context of a shell script. How are you passing the commands to sftp? If you're using the -b switch, I cannot replicate your problem; I have successfully used it to upload a file and change its permissions.
– DopeGhoti
May 15 '16 at 21:14




You say that you're using sftp in the context of a shell script. How are you passing the commands to sftp? If you're using the -b switch, I cannot replicate your problem; I have successfully used it to upload a file and change its permissions.
– DopeGhoti
May 15 '16 at 21:14












1) the only error message i receive is invalid command. the command, i pass through the script is quote site chmod 750 $file.txt, after the put command. The put is successful. When, i do it manually, i am not receiving any error. It is successful. Only when done via script it errors me out. there are 2 files i ftp and both are able to be sftp'ed.
– Sravani
May 16 '16 at 14:55




1) the only error message i receive is invalid command. the command, i pass through the script is quote site chmod 750 $file.txt, after the put command. The put is successful. When, i do it manually, i am not receiving any error. It is successful. Only when done via script it errors me out. there are 2 files i ftp and both are able to be sftp'ed.
– Sravani
May 16 '16 at 14:55












I am passing the commands via a script. I am not using the -b. I specified all the parameters in the script first and then pass the parameters in the command.The only commands i used in the script is sftp username@hostname put file1 put file 2 quote site chmod 775 file 1 quote site chmod 775 file 2 is there any other command i have to use, when i am doing the sftp and trying to do chmod.
– Sravani
May 16 '16 at 14:57





I am passing the commands via a script. I am not using the -b. I specified all the parameters in the script first and then pass the parameters in the command.The only commands i used in the script is sftp username@hostname put file1 put file 2 quote site chmod 775 file 1 quote site chmod 775 file 2 is there any other command i have to use, when i am doing the sftp and trying to do chmod.
– Sravani
May 16 '16 at 14:57













sftp username@hostname put file1 put file2 quote site chmod 750 $file1 quote site chmod 750 $file2 quit EOF
– Sravani
May 16 '16 at 15:01




sftp username@hostname put file1 put file2 quote site chmod 750 $file1 quote site chmod 750 $file2 quit EOF
– Sravani
May 16 '16 at 15:01










1 Answer
1






active

oldest

votes

















up vote
0
down vote













  • Change the permission for the file at your end before connecting to server via SFTP, same as how you want to write permissions at server

  • Connect to server via SFTP

  • use -p option in put
    sftp> put -p





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',
    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%2f283332%2fchanging-permissions-of-the-file-while-using-sftp-command-in-a-shell-script%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
    0
    down vote













    • Change the permission for the file at your end before connecting to server via SFTP, same as how you want to write permissions at server

    • Connect to server via SFTP

    • use -p option in put
      sftp> put -p





    share|improve this answer
























      up vote
      0
      down vote













      • Change the permission for the file at your end before connecting to server via SFTP, same as how you want to write permissions at server

      • Connect to server via SFTP

      • use -p option in put
        sftp> put -p





      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        • Change the permission for the file at your end before connecting to server via SFTP, same as how you want to write permissions at server

        • Connect to server via SFTP

        • use -p option in put
          sftp> put -p





        share|improve this answer












        • Change the permission for the file at your end before connecting to server via SFTP, same as how you want to write permissions at server

        • Connect to server via SFTP

        • use -p option in put
          sftp> put -p






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '17 at 10:29









        Shyam

        1




        1



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f283332%2fchanging-permissions-of-the-file-while-using-sftp-command-in-a-shell-script%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)