1

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 ?

Falcon
  • 11
  • 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" – steeldriver Dec 05 '21 at 13:14
  • 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. – Falcon Dec 06 '21 at 06:55

0 Answers0