Skip to main content
Solved

Run Script as Logged in User - Collect Application Logs - Vectorworks


Forum|alt.badge.img+4

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.

Best answer by iGuessRo

@mcgace

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"
View original
Did this topic help you find an answer to your question?

8 replies

Forum|alt.badge.img+4
  • New Contributor
  • 23 replies
  • December 10, 2019

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


Forum|alt.badge.img+4
  • Author
  • Contributor
  • 16 replies
  • December 10, 2019

@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

donmontalvo
Forum|alt.badge.img+36
  • Legendary Contributor
  • 4293 replies
  • December 10, 2019

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.


Forum|alt.badge.img+4
  • New Contributor
  • 23 replies
  • December 10, 2019

@mcgace Are you getting any of those logs back when running this policy from self service?


Forum|alt.badge.img+4
  • Author
  • Contributor
  • 16 replies
  • December 10, 2019

@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


Forum|alt.badge.img+4
  • New Contributor
  • 23 replies
  • Answer
  • December 10, 2019

@mcgace

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"

Forum|alt.badge.img+4
  • Author
  • Contributor
  • 16 replies
  • December 11, 2019

@r... Thanks that worked. I now get an output like the one below.

What does double quotes around the variable mean?


Forum|alt.badge.img+4
  • New Contributor
  • 23 replies
  • December 11, 2019

@mcgace

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings