Skip to main content
Solved

Need to place a file from web to a user library folder


Forum|alt.badge.img+3

Hi all, newbie to scripting and Jamf, so please bear with me here. 

 

I would like to create a script that pulls a config file for our VPN client and places it in the users library/application support/application/config folder. I think the script would be as follows: 

#!/bin/bash

curl https://website.com/place/file.plist -o ~/Library/Application\\ Support/ApplicationName/Config/file.plist

Does this look like it would work to download to the users Library folder? 

 

Edit: input the -o in the middle of the curl line, forgot to input that there!

Best answer by dwbergstrom

You'd probably want to use the absolute path here with the user's name plugged in as a variable, so something like:

 

#!/bin/sh

loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name 😕😕 && ! /loginwindow/ { print $3 }' )

curl https://website.com/place/file.plist -o "/Users/$loggedInUser/Library/Application\\ Support/ApplicationName/Config/file.plist"

 

 

 

Also don't forget the quotes around the destination path since there are spaces.

 

View original
Did this topic help you find an answer to your question?

6 replies

dwbergstrom
Forum|alt.badge.img+4
  • New Contributor
  • 14 replies
  • Answer
  • September 29, 2021

You'd probably want to use the absolute path here with the user's name plugged in as a variable, so something like:

 

#!/bin/sh

loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name 😕😕 && ! /loginwindow/ { print $3 }' )

curl https://website.com/place/file.plist -o "/Users/$loggedInUser/Library/Application\\ Support/ApplicationName/Config/file.plist"

 

 

 

Also don't forget the quotes around the destination path since there are spaces.

 


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 8 replies
  • September 29, 2021

Just tried running this in terminal by typing sh /locationofthisscript.sh and hitting enter, but got a 'awk: syntax error at line 1 . Was there something in there about an emoji?


dwbergstrom
Forum|alt.badge.img+4
  • New Contributor
  • 14 replies
  • September 29, 2021

Sorry, weird editing issue.  I think it's fixed now.  And I see you did have -o for output there already.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 8 replies
  • September 29, 2021
dwbergstrom wrote:

Sorry, weird editing issue.  I think it's fixed now.  And I see you did have -o for output there already.


So ran that as well and the output  was the same unfortunately. Just wondering though, what does this emoji have to do with pulling the current users account name?


dwbergstrom
Forum|alt.badge.img+4
  • New Contributor
  • 14 replies
  • September 29, 2021

It's because I apparently can't figure out the text formatting - I'm not sure how it ended up there.  I think this new edit should be better.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 8 replies
  • September 29, 2021

OHHH I googled the beginning part of it and the emoji is = colon forward slash. When you input that in this text field, the formatting changes it automatically. ðŸ˜‹ I input the change to the script and it worked! Thanks!!


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