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

jaycruz145
New Contributor III

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!

1 ACCEPTED SOLUTION

dwbergstrom
New Contributor III

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 solution in original post

6 REPLIES 6

dwbergstrom
New Contributor III

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.

 

jaycruz145
New Contributor III

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
New Contributor III

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
New Contributor III

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.

jaycruz145
New Contributor III

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!!