First script is called wa.sh Here is the code:
#!/bin/bash
sleep 2
/opt/Citrix/ICAClient/selfservice --icaroot /opt/Citrix/ICAClient
VDI=`pidof wfica | wc -w`
echo $VDI
while [ $VDI -eq 0 ]
do
sleep 1
echo "VDI is not running"
VDI=`pidof wfica | wc -w`
done
echo "gonig to if.sh"
/opt/Scripts/if.sh&
Contents of if.sh - the second script
#!/bin/bash
VDI=`pidof wfica | wc -w`
echo $VDI
while [ $VDI -eq 1 ]
do
sleep 1
echo "Vdi is currently running"
VDI=`pidof wfica | wc -w`
done
pkill -u $(whoami)
When the first script is invoked by a .bashrc after guest user logs in to ubuntu it doesn't invoke the second script - if.sh The logic behind this is that when user logs on to guest session, selfservice starts and VDI = 0 User enters correct credentials and starts his session VDI = 1 and that's when we need to start monitoring when VDI becomes 0 again to logoff guest session. I have already tried to invoke the second script with source, exec and $() to no avail.
.bashrc? Do you see the output fromecho $VDI? Do you see output fromecho "gonig to if.sh"? Addset -xto the top of the first script and see what actually runs. The second script too if you want to be sure it isn't running (or to see what it is doing if it does get run). – Etan Reisner Aug 27 '15 at 13:46.bashrcfile run correctly? Show the.bashrcfile? – Etan Reisner Aug 27 '15 at 13:57.bashrcis started for non-login, interactive shells. You probably want to put this in.bash_profileinstead; it's possible that your tests are already seeing an instance ofwficastarted by a previous shell, so thatwa.shnever gets past its loop. – chepner Aug 27 '15 at 14:07