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.

share|improve this question
    
What is the output from the first script when used in the .bashrc? Do you see the output from echo $VDI? Do you see output from echo "gonig to if.sh"? Add set -x to 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
    
When started by .bashrc there is no output or I don't know how to check it. When I login to guest session, open terminal and start the script with bash scriptname it works as expected (second script as well). Echoes everything. Tried already set -x and bash -nx but only from therminal when it works ok. – d.olejarz Aug 27 '15 at 13:48
    
Do other things in the .bashrc file run correctly? Show the .bashrc file? – Etan Reisner Aug 27 '15 at 13:57
    
There is nothing unusuall in .bashrc apart from a line that starts the first script. There it is: pastebin.com/g0bgWNSX – d.olejarz Aug 27 '15 at 14:06
1  
.bashrc is started for non-login, interactive shells. You probably want to put this in .bash_profile instead; it's possible that your tests are already seeing an instance of wfica started by a previous shell, so that wa.sh never gets past its loop. – chepner Aug 27 '15 at 14:07

It was a problem with permissions on guest account. Re-wrote them scripts into a daemon and all is working fine now.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.