Denis Heidtmann wrote:
> On Fri, Apr 2, 2010 at 2:01 PM, Fred James <[email protected]>wrote:
>
>   
>> Denis Heidtmann wrote:
>>     
>>> On Fri, Apr 2, 2010 at 12:39 PM, Denis Heidtmann
>>> <[email protected]>wrote:
>>>
>>>
>>>       
>>>> On Fri, Apr 2, 2010 at 11:55 AM, Joe Pruett <[email protected]> wrote:
>>>>
>>>>
>>>>         
>>>>> bash 3.2 on my system doesn't show this problem.  are you sure the full
>>>>> path and relative path actually get to the same script?  could you be
>>>>> accidentally running two different scripts?  or maybe it is some odd
>>>>> bash bug, what version do you have?
>>>>>
>>>>>
>>>>>           
>>>> Since /etc/gdm/PostSession/Default is a .sh script, I must use that
>>>>         
>> shell,
>>     
>>>> also known as dash.  Maybe bash will not show the problem.  I have
>>>>         
>> version
>>     
>>>> 3.2.48(1)-release (x86_64-pc-linux-gnu).
>>>>
>>>> -Denis
>>>>
>>>> It turns  out that I jumped to an  invalid conclusion.  The issue is not
>>>>
>>>>         
>>> with bash, but with dash.   But my problem remains.  I need to use dash,
>>>       
>> and
>>     
>>> the policy wants the script to be sourced.  My only solution at this time
>>>       
>> is
>>     
>>> to have a separate script with the argument coded into it.  I would
>>>       
>> prefer
>>     
>>> not to do that, but even more I would like to understand the behavior.
>>>
>>> -Denis
>>>
>>>       
>> Dennis Heidtmann
>> Well, first let's see if we are on the same page ... OK?
>>    I run Mandriva 2008 and ...
>>    (1) /bin/sh -> bash
>>    (2) instead of /etc/gdm/PostSession/Default I have
>> /etc/X11/gdm/PostSession/Default
>>    (2.1) I have included the text of /etc/X11/gdm/PostSession/Default
>> below for comparison
>>    (3) if we are anywhere near on the same  page ... could you show me
>> what you are trying to do?
>> ... hoping to help
>> Regards
>> Fred James
>>
>> [text of /etc/X11/gdm/PostSession/Default from Mandriva 2008]
>> #!/bin/sh
>>
>> PATH="/usr/bin:$PATH:/bin:/usr/bin"
>> OLD_IFS=$IFS
>>
>> gdmwhich () {
>>  COMMAND="$1"
>>  OUTPUT=
>>  IFS=:
>>  for dir in $PATH
>>  do
>>    if test -x "$dir/$COMMAND" ; then
>>      if test "x$OUTPUT" = "x" ; then
>>        OUTPUT="$dir/$COMMAND"
>>      fi
>>    fi
>>  done
>>  IFS=$OLD_IFS
>>  echo "$OUTPUT"
>> }
>>
>> exit 0
>>
>> I want to log the time of logoff.  I was directed to
>>     
> gdm/PostSession/default by:
>
> http://people.uleth.ca/~daniel.odonnell/Blog/lost-in-logout-land-running-scripts-on-login-and-logout-partially-solved-but-interesting-anyway
>
> Method 1: /etc/gdm/PostLogin/Default, /etc/gdm/PreSession/Default, and
> /etc/gdm/PostSession/Default
>
> "If you have a shell script that does not require user intervention, you can
> run it automatically immediately after Login, immediately before the start
> of the Gnome Session (i.e. before the desktop is drawn), and immediately
> after your Gnome Session (i.e. after the Desktop closes down), by launching
> it from /etc/gdm/PostLogin/Default, /etc/gdm/PreSession/Default, and
> /etc/gdm/PostSession/Default respectively. "
>
> I do not understand the function gdmwhich.  I just added a line executing my
> script, using the fully qualified path.  The argument of the script, Logoff,
> is placed in my log file, since other events get put in that file as well.
>  If I source my script rather than executing it, the argument does not get
> received by my script.
>
> I am running ubuntu 9.04
>
> This is not a huge problem.  I can create a duplicate of my script which has
> Logoff hard-coded into it.  But I would like to understand why dash does not
> pass the argument when the script is sourced.
>
> Is there a way for my script to detect that it is sourced rather than
> executed?
>
> -Denis
>   
Denis Heidtmann (sorry ... I have been misspelling your name ... sorry)
To be clear ...
First, my system
    does not have any files in the /PostLogin directory
    does have a Default script in each of the PreSession and PostSession 
directories, but no other files are found there
Second, I am not sure the Default files you have are exactly like the 
ones I have

However ... assuming they are similar at least ...

gdmwhich () {} ...
Pre gdmwhich ()  the value of IFS is saved and then set to :
Then the directories in $PATH are searched for a match to COMMAND (which 
is set to $1)
If the COMMAND is found and it is executable (test -x) and if the OUTPUT 
is an empty variable (since OUTPUT= the "x$OUTPUT" should be "x")
    set OUTPUT to be the directory in which COMMAND was found, followed 
by COMMAND (inserting the required /, of course)
Reset IFS to its old value
"echo" or return that value of $OUTPUT

So far so good?

Now ... in both my PreSession and PostSession, the PATH is set to 
include $PATH, /bin, and /usr/bin, although in PostSession /usr/bin is 
listed twice (see above in quoted message)
In my PreSession there is the line ...
       XSETROOT=`gdmwhich xsetroot`
... note that those are the forward single quotes (normally found on the 
'~' key?), which calls the function with the argument xsetroot, setting 
XSETROOT to whatever is returned (echo'd)
    in other words the value of XSETROOT is whatever directory gdmwhich 
() finds xsetroot in, followed by /, followed by xsetroot - in my case 
that would be /usr/bin/xsetroot - your mileage may vary.
That does assume that xsetroot is found, of course, otherwise OUTPUT is 
empty.

Does any of that help, or did I miss something?
Regards
Fred James

_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to