linux - Echoing password to command with rc.local -


we have command handle joining of our rhel7 servers privilege manager sudo not working when ran rc.local script. command below more generic names instead of our specific assets.

echo "password" | /opt/quest/sbin/pmjoin_plugin -b -a -v -q -d masterport=12345 -d failovertimeout=10 -d selecthostrandom=yes somehostname.com someotherhostname.com >> /var/log/build.log

the command when ran manually or other bash scripts work perfection, when executed within rc.local, if password not being piped command when prompted password.

i've read suggestions such "plymouth quit" has not helped.

anyone out there have experience "echoing" password command way within rc.local script can proceed through interactive script prompts password?

ultimately, want have run when instance first booted. if there way have shell script run once on boot , delete without rc.local explore route (crontab, etc?).

i ended implementing solution worked situation. while it's not clean letting things run in rc.local, job done.

i took command out of our rc.local script , put it's own .sh script. our ami build process stores @ /tmp/nameofscript.sh , created systemd service file ami process storing in /etc/systemd/system/nameofservicefile.service. service file executes execstart=/tmp/nameofscript.sh in run on reboot. our rc.local runs in phase1 , phase2 sort of manner, phase1 rebooting @ end, added line phase1 portion enable service "systemctl enable nameofservicefile.service" before reboot happens last step of phase1.

going route enabled pm sudo join command runs during our "phase2" steps since reboot @ end of "phase1" triggered script systemd service.

to ensure doesn't run on every reboot, /tmp/nameofscript.sh script has steps rm -f /etc/systemd/system/nameofservicefile.server , delete rm -- "$0".

probably messy way this, gets job done.