0

I'm quite new to shell scripting . I wanted to mount a NFS share[volume1] and switch to a LDAP user[user001@ldap.com]in the NFS volume and perform some operations via shell script . example

    #!/bin/sh
    echo "switch to ldap user"
    su user001@ldap.com
    mount -o nfsvers=3,minorversion=0 <server-ip>:/<nfsvol> <mountpoint>
    echo "mount done"
    touch abc.txt

I was able to do it in the script till i switch to the user001.But after switching to user001 , script didnt get executed and script control came to user001@ldap.com@shell] and was expecting my input

Only when I give exit , script proceeded . Please let me know how to switch as a new user and continue with the operations. Thanks in advance

User01
  • 27
  • 4
  • 3
    Does this answer your question? [can I run 'su' in the middle of a bash script?](https://stackoverflow.com/questions/3420280/can-i-run-su-in-the-middle-of-a-bash-script) – JJ Hassan Mar 29 '21 at 14:49
  • Thanks for the suggestions . – User01 Mar 31 '21 at 10:28

0 Answers0