Posted on 12-10-2019 02:52 AM
Hi guys,
I am trying to run a script as a Self Service policy that will collect Vectorworks log files from a Users machine and add it as an attachment in the device's inventory.
I found this script by Matt Taylor that is really good:
https://github.com/matt-taylor934/loguploader/blob/master/loguploader.sh
But I can't figure out how to get it to include the Vectorworks log file at this location: /Users/logged.in.user/Library/Application Support/Vectorworks/2019/VW User Log.txt
I added a variable for the location of the log file to the compressed zip $vwFileLocation but its not int he output:
I guess it needs the logged in user? I don't know how to get the logged in user. Or does it need to run as the logged in user and how do I do that?
Scripting is very new to me so any help would be appreciated.
Solved! Go to Solution.
Posted on 12-10-2019 11:49 AM
Lets try putting double quotes around your VW Log variable when calling it back in zip
## Compress the log files we're uploading and name it with a timestamp.
/usr/bin/zip -r -j $logArchive $jamfLog $installLog $systemLog "$vwUserLog"
Posted on 12-10-2019 06:09 AM
Try using this as the variable for logged in user
currentUser=$(ls -l /dev/console | awk '{ print $3 }')
Then you can call that variable back in your path
/Users/$currentUser/Library/Application Support/Vectorworks/2019/VW User Log.txt
Posted on 12-10-2019 08:25 AM
@r... I tried that but no luck, still not working.
My Syntax:
## Get User Name.
currentUser=$(ls -l /dev/console | awk '{ print $3 }')
# Specify the log files being requested.
jamfLog="/var/log/jamf.log"
installLog="/var/log/install.log"
systemLog="/var/log/system.log"
vwUserLog="/Users/$currentUser/Library/Application Support/Vectorworks/2019/VW User Log.txt"
## Compress the log files we're uploading and name it with a timestamp.
/usr/bin/zip -r $logArchive $jamfLog $installLog $systemLog $vwUserLog
Posted on 12-10-2019 08:38 AM
Might post entire script, don't see $logArchive
(the zip archive being created) path being defined.
EDIT: Never mind I see you posted the GitHub URL to the script.
Posted on 12-10-2019 08:52 AM
@mcgace Are you getting any of those logs back when running this policy from self service?
Posted on 12-10-2019 09:07 AM
@r... yes I get a zip file with the three log files (install.log, jamf.log system.log) but not the one I'm trying to get for Vectorworks
Posted on 12-10-2019 11:49 AM
Lets try putting double quotes around your VW Log variable when calling it back in zip
## Compress the log files we're uploading and name it with a timestamp.
/usr/bin/zip -r -j $logArchive $jamfLog $installLog $systemLog "$vwUserLog"
Posted on 12-11-2019 02:48 AM
@r... Thanks that worked. I now get an output like the one below.
What does double quotes around the variable mean?
Posted on 12-11-2019 06:13 AM
The variable you were calling has spaces in the file name, the double quotes allow the variable to be called back with those spaces intact. I also included the -j switch so it would junk the directories and just keep the log files
Happy to read you're up and running