Score:1

GDM logout script doesn't write to a file

us flag

I'm trying to write a logout script that will be executed when a user graphically logout.
For this purpose I've added the script into the file: /etc/gdm3/PostSession/Default

In the script I'm writing into a file and creating 2 new files with touch:

#!/bin/sh
touch /home/userA/Documents/file_A.txt
my_file="/home/userA/Documents/.proj/file.txt"
echo "Hello" >> $my_file
touch /home/userA/Documents/file_B.txt

NOTE: .proj folder already exist.

The issue is that if I run the /etc/gdm3/PostSession/Default script using the terminal it works well, but if I logout graphically then the script performs the touch commands, therefore performs the echo command as well, but the actual write to the file doesn't happen.
I'm using Ubuntu 20.04.3 LTS.
Any suggestion what am I doing wrong here ?

hr flag
Does your script have a shebang? Most common shells don't permit spaces around the `=` in an assignment - it needs to be `my_file="/home/userA/Documents/.proj/file.txt"`
shlomi93 avatar
us flag
yes it contains !#/bin/sh at the top. the spaces around the `=` are typo and doesn't exist in the real code. I've edited the post accordingly.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.