AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
#Operatingsystems
#Servers
 View Only
  • 1.  Unable to run a command from user in Single Line CLI - need help

    Posted 10/01/13 10:30 AM

    Originally posted by: SubhadipDas


    I am having a problem while running a script which requires su - 

    The command that I need to run is - 
    echo -e "* ACL_type NFS4\n s:(EVERYONE@): a rwpRWxDaAdcCos\n s:(OWNER@): a rwpRWxDaAdcCos\n s:(GROUP@): a rwpRWxDaAdcCos"|aclput /mount_ACL_233

    Now from root, the command is running fine on one of the NFS export which is connected to the AIX client, but the problem comes when i want to run this command from one particular user - 

    bash-4.2# su - user_g -c "echo -e "* ACL_type NFS4\n s:(EVERYONE@): a rwpRWxDaAdcCos\n s:(OWNER@): a rwpRWxDaAdcCos\n s:(GROUP@): a rwpRWxDaAdcCos"|aclput /mount_ACL_233"
    bash: syntax error near unexpected token `('

    user_g is an user who has sufficient ACL rights to change the ACL of the mountpoint there. There is no other error/problem from me related to permission of the user. Just I am unable to get how to get the actual error-free single command line for this? 

    I have tried it with that user only and it passed. But I want to run the whole command in single line. Can anyone help?


    #AIX-Forum


  • 2.  Re: Unable to run a command from user in Single Line CLI - need help

    Posted 10/02/13 12:55 PM

    Originally posted by: GU0H_Jorge_Gutierrez


    From a quick look, it seems your original command is having quoutes, so the embracing quotes for the -c  are being closed early :

    ash-4.2# su - user_g -c "echo -e "* ACL_type NFS4\n s:(EVERYONE@): a rwpRWxDaAdcCos\n s:(OWNER@): a rwpRWxDaAdcCos\n s:(GROUP@): a rwpRWxDaAdcCos"|aclput /mount_ACL_233"

     

    So su is receiving echo - e as the only command to run and then a bunch of unkown stuff.

    My advice is to escape any of the original quotes with \" like:

     su - user_g -c "echo -e \"* ACL_type NFS4\n s:(EVERYONE@): a rwpRWxDaAdcCos\n s:(OWNER@): a rwpRWxDaAdcCos\n s:(GROUP@): a rwpRWxDaAdcCos\"|aclput /mount_ACL_233"

     


    #AIX-Forum


  • 3.  Re: Unable to run a command from user in Single Line CLI - need help

    Posted 10/04/13 12:57 AM

    Originally posted by: SubhadipDas


    Hi,

     

    I have tried to run this command with the escape characters as suggested, but got this new error. 

    sh-4.2# su - user_g -c "echo -e \"* ACL_type NFS4\n s:(EVERYONE@): a rwpRWxDaAdcCos\n s:(OWNER@): a rwpRWxDaAdcCos\n s:(GROUP@): a rwpRWxDaAdcCos\"|aclput /mount_ACL_233"

    Invalid ACL textual format
     

    The ACL textual format is proper as the command is running properly when I dont give the username. :(

    What I am doing wrong here??


    #AIX-Forum


  • 4.  Re: Unable to run a command from user in Single Line CLI - need help

    Posted 10/09/13 07:23 AM

    Originally posted by: teletype


    You should probally escape your newllines as well (\n becomest \\n ore even \\\n).

    I dont know the aclput command but a quick look at the manpage learns that it has a -i flag to read from a file. Maybe you could create a file and feed it to aclput? That way you do not have to escape all kind of caracters. And your script will probaly more (human) readable.

    Hope this helps

     

     


    #AIX-Forum


  • 5.  Re: Unable to run a command from user in Single Line CLI - need help

    Posted 10/09/13 08:21 AM

    Originally posted by: Wouter Liefting


    Why not put the whole command in a shell script, and run the shell script using this:

    su - user_g -c ./myscript

    Oh, and looking at what you're trying to achieve, there is no need for the echo command to run under su. Only the aclput command needs to run as user_g. So instead of

    su - user_g -c "echo stuff | aclput /mount_ACL_233"

    with all its quoting issues you should also be able to do

    echo stuff | su - user_g -c aclput /mount_ACL_233

    which means you don't need to escape the stuff you want to echo.


    #AIX-Forum