I am porting Serv-U from Windows to Linux, and am working on converting some home-made batch scripts into shell scripts. I have the shell scripts working correctly so there is no issue with migration. The script collects account name and the location of the user's home folder. The purpose of the script is to send the contents of the upload directory to a list of recipients after the account disconnects the session. The list of recipients is obtained from a specified file at $recipLoc/$name.txt (see below), and for a test example the recipients file only contains one valid email address. Here is the script below.
#!/bin/bash
name=$1 ## Passes in $Name variable from Serv-U.
mailboxPath=$2 ## Passes in $LocalHomeDirectory variable from Serv-U.
fileListLoc=/usr/local/Serv-U/temp
recipLoc=/usr/local/Serv-U/Scripts/recipients
echo "Files were uploaded to the $mailboxPath/Upload directory." >> $fileListLoc/$name.txt
# list the contents of the Upload directory and store the output to the specific file
ls $mailboxPath/Upload >> $fileListLoc/$name.txt
##Send email using Postfix, with the body of the email being the contents of the file at $fileListLoc/$name.txt
cat $fileListLoc/$name.txt | mail -s "Files in FTP1 Mailbox $name" $recipLoc/$name.txt
When I execute the shell script using the console while manually defining the parameters, I am successfully able to receive an email (for example, ./Notification.sh user path/to/files 5).
The first issue I am experiencing is that there is no file being created in the temp folder of the output of the directory.
The second issue I am experiencing is that the log in Serv-U shows the script is being executed with defined parameters when the user logs out, but no email is being generated. If I check the /var/log/maillog file, there is no line item that an email was sent.
There are about 400 accounts using Serv-U so it would be easiest to get this script to work instead of modifying the configuration files for each of the 400+ accounts. Any help that you could provide will be extremely valuable.
Thanks!
Travis