I've recently been sussing out the behaviors of echo in various shells, I think it important to note the differences in echo across the carious I'm running macOS 12.0.1 and Jamf 10.33.0 if that might have something to do with it. When I run it from a policy in Jamf the line breaks don't come through, and it shows "\n" for the breaks. to add two line breaks between paragraphs" "Understood" "Alert" When I run the command from a local script./test.sh null null null "Warning" "" "Long bit of text with "$jhPath" -windowType utility -title "$Title" -heading "$Head" -alignHeading center -description "$msg" -button1 "$7" -icon "$Icon" Icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns" Icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns" Icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertCautionIcon.icns" Icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Actions.icns" but now the new lines aren't registering. I'm sure this worked when I first setup my script. See the following test script below for how to make it work: #!/bin/shĬurious. You just have to know how to get the script to recognize it. You might also need to do a quick if/then check to make sure both parameters are assigned before setting the $Msg variable, or set it appropriately if only $Desc1 is actually assigned, for but actually you can make the \n work in the script. Not as nice as being able to enter it directly into the JSS policy in one field, but it works (as long as you don't require a 3rd line or something) In my super quick test just now, I was able to pass 2 separate parameters to it that combined into one description for the message, with a break in the lines between them. "$jhPath" -windowType utility -title "$Title" -description "$Msg" -button1 "OK" -icon "$Icon" In your actual script that displays the message, do something like this: #!/bin/sh Set up 2 parameters (in addition to any others you need) for your script and when its in the JSS. So, just thinking this through on one side of my brain as I do other things, I think the following may work, though its kind of crude. Just thought I'd mention that in case you run into the same thing. Trying to escape the quotes like "quoted text" failed, but doing "Quoted text" directly in the parameter field worked fine. Same if I wanted to quote some text in the message. It was the opposite when using a direct jamf runScript call. In doing some tests with the above example, I found I didn't need to have an escaped new character in the parameter, such as \n. The command 'sudo jamf runScript -script "ScriptName.sh" -path, etc seems to handle line breaks and other escaped stuff differently than when passing a parameter to a script from a policy. You can add as many as you like in one parameter, and it also doesn't use more than one parameter in the policy.Īs for getting html messages with formatting and background images, etc, sorry, can't help you there )Įdit: Quick additional note. It also doesn't matter how many lines you need. The cool thing about this is its pretty flexible because if your message doesn't have any line break characters in it, it doesn't matter. I can even do this in the message to get a blank line between: This is line 1.\ I just ran this through a quick test and setting up $4 with the line: "This is the first line of the message.\Īctually gave me something like this in the jamfHelper window. I haven't tested it, but I think using printf may also do the trick here. This works because echo will recognize the newline character, \n, and translate it into actual line breaks as it sets up the final message variable to pass into jamfHelper. The trick above is to use 'echo' to set up a new variable from the one passed in the parameter. Sudo "$jhPath" -windowType utility -title "My Title" -description "$MSG" -button1 "OK" -defaultButton 1 # The new message variable passed to jamfHelper # Description passed in from parameter set in the policy JhPath="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" See the following test script below for how to make it work: #!/bin/sh But actually you can make the \n work in the script.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |