Posted on 08-29-2013 06:44 AM
i have a script i have created to do this but i keep getting a error code when i try to use casper remote to push it to a test machine.
The script does the following. ```
Sudo dseditgroup -o edit -n /Local/Default -u admin -p -a printerusers -t group lpadminn
exit 0
```
When i push this out it gives a error.
Sending Wake On LAN command...
Opening SSH Connection to 192.168.17.182...
Authenticating...
Successfully authenticated.
Verifying Computer's Identity...
The MAC Address has been verified.
Checking Operating System Version...
Running Mac OS X 10.8.4 (12E3067)
Verifying /usr/sbin/jamf...
/usr/sbin/jamf is current (8.71)
Verifying /usr/sbin/jamfvnc...
/usr/sbin/jamfvnc does not exist.
Verifying /Library/Preferences/com.jamfsoftware.jamf.plist...
Preparing Policy...
Switching servers for load balacing...
Executing Policy 2013-08-29 at 8:42 AM | tekhelp | 1 Computer...
Creating directory structure for /Library/Application Support/JAMF/Downloads/
Downloading name of server where script is located.
Running script printer4.sh...
Script exit code: 2
Script result: /private/tmp/printer4.sh: line 1: syntax error near unexpected token `newline'
/private/tmp/printer4.sh: line 1: `'
Submitting log to name of server where casper is located.
Finished.
If any one can help me trouble shoot this that would be great. I have only started to create shell scrips.
Solved! Go to Solution.
Posted on 08-29-2013 08:36 AM
Hi. Several things I see here that need to be fixed.
For one, you don't need to provide a username in your dseditgroup command since, if its running from Casper. it runs as root. Second, using the -p (lowercase p) with dseditgroup means it will prompt interactively for the password for your 'casperrecon' account, which is going to fail since there is no interactive console when it runs. Just remove the whole -u casperrecon -p section in the script to start.
Second, the error you're getting about unexpected `newline` often means there's a formatting issue with the script. Some characters in it that the shell doesn't like typically. How did you create and save the script? I would recommend rewriting it from scratch with something like TextWrangler. Its free from the App Store and works great for scripts since it makes sure to properly format any scripts as plain text. You can also do it from TextEdit, but make sure you create a new file (don't use an existing file) and convert it to Plain Text from the menu before doing anything. Save with the .sh extension and it should work.
Also, use the second script that gets the current logged in user, not your first attempt. since that would not work (again, the script runs as root, so you have to direct it to affect the logged in user)
Posted on 08-29-2013 10:48 AM
Does it work over AFP/SMB?
Posted on 08-29-2013 07:12 AM
i have also just tried this step.
#!/bin/bash
currentUser=`ls -la /dev/console | awk '{print $3}'`
dseditgroup -o edit -n /Local/Default -u casperrecon -p -a $currentUser -t user lpadmin
exit 0
It is giving this error
Sending Wake On LAN command...
Opening SSH Connection to 192.168.17.182...
Authenticating...
Successfully authenticated.
Verifying Computer's Identity...
The MAC Address has been verified.
Checking Operating System Version...
Running Mac OS X 10.8.4 (12E3067)
Verifying /usr/sbin/jamf...
/usr/sbin/jamf is current (8.71)
Verifying /usr/sbin/jamfvnc...
/usr/sbin/jamfvnc does not exist.
Verifying /Library/Preferences/com.jamfsoftware.jamf.plist...
Preparing Policy...
Executing Policy 2013-08-29 at 9:11 AM | tekhelp | 1 Computer...
Creating directory structure for /Library/Application Support/JAMF/Downloads/
Downloading https://pathtomyserver/caspershare
Running script printer4.sh...
Script exit code: 2
Script result: /private/tmp/printer4.sh: line 1: syntax error near unexpected token `newline'
/private/tmp/printer4.sh: line 1: `'
Submitting log to https://pathtomyserver
Finished.
Posted on 08-29-2013 08:36 AM
Hi. Several things I see here that need to be fixed.
For one, you don't need to provide a username in your dseditgroup command since, if its running from Casper. it runs as root. Second, using the -p (lowercase p) with dseditgroup means it will prompt interactively for the password for your 'casperrecon' account, which is going to fail since there is no interactive console when it runs. Just remove the whole -u casperrecon -p section in the script to start.
Second, the error you're getting about unexpected `newline` often means there's a formatting issue with the script. Some characters in it that the shell doesn't like typically. How did you create and save the script? I would recommend rewriting it from scratch with something like TextWrangler. Its free from the App Store and works great for scripts since it makes sure to properly format any scripts as plain text. You can also do it from TextEdit, but make sure you create a new file (don't use an existing file) and convert it to Plain Text from the menu before doing anything. Save with the .sh extension and it should work.
Also, use the second script that gets the current logged in user, not your first attempt. since that would not work (again, the script runs as root, so you have to direct it to affect the logged in user)
Posted on 08-29-2013 08:40 AM
Hi,
We are using the string usr/sbin/dseditgroup -o edit -n /Local/Default -a everyone -t group lpadmin in our script and it makes a good job.
Posted on 08-29-2013 08:44 AM
Everything Mike said.
I suspect the specific error you're seeing isn't directly an issue with the script. Although 'sudo' is probably not needed and, if used, it's probably best practice to use all lowercase so it doesn't cause issues if it's moved to a case sensitive filesystem. The server is probably giving an error message which is being misinterpreted. Try downloading the script directly with a web browser, you may need credentials if your web share requires authentication.
The address to use can be found on the line that says "Downloading https://pathtomyserver/caspershare". Put the unedited version of this line in a web browser and see what you get. If it can't find the script, did you remember to replicate to this share, if it's not the root share? It it complains that it doesn't have rights to the file, are the permissions on the script such that the web process can at least read it?
Posted on 08-29-2013 10:31 AM
Ok thanks for the responses. I have made some of the changes that MM2270 recommended and i am still getting an error when i send the script out.
The script that i am using now.
#!/bin/bash
currentUser=`ls -la /dev/console | awk '{print $3}'`
dseditgroup -o edit -n /Local/Default -a $currentUser -t user lpadmin
the error i am getting now.
Sending Wake On LAN command...
Opening SSH Connection to 192.168.17.182...
Authenticating...
Successfully authenticated.
Verifying Computer's Identity...
The MAC Address has been verified.
Checking Operating System Version...
Running Mac OS X 10.8.4 (12E3067)
Verifying /usr/sbin/jamf...
/usr/sbin/jamf is current (8.71)
Verifying /usr/sbin/jamfvnc...
/usr/sbin/jamfvnc does not exist.
Verifying /Library/Preferences/com.jamfsoftware.jamf.plist...
Preparing Policy...
Switching servers for load balacing...
Executing Policy 2013-08-29 at 12:19 PM | tekhelp | 1 Computer...
Creating directory structure for /Library/Application Support/JAMF/Downloads/
Downloading http://sub.domain.org:80//Scripts/dsedit.sh...
Running script dsedit.sh...
Script exit code: 2
Script result: /private/tmp/dsedit.sh: line 1: syntax error near unexpected token `newline'
/private/tmp/dsedit.sh: line 1: `'
Submitting log to https://sub.domain.org:8443//...
Finished.
I have created the script in text wrangler and i created the 1st script in pico via the terminal.
I am still getting the syntax error.
Posted on 08-29-2013 10:48 AM
Does it work over AFP/SMB?
Posted on 08-29-2013 10:53 AM
Then I would try the steps Josh_S outlines above. It could be that the script isn't getting downloaded at all to the destination. You may need to verify that its accessible from the DP the Mac is trying to grab it from.
Because honestly there doesn't appear to be anything wrong with your script at all. The only thing I might do is enclose the $currentUser variable in quotes in the dseditgroup line as a just in case, but not having that shouldn't give you the error you're seeing. If you created it in pico or TextWrangler the formatting shouldn't be a factor at this point.
Posted on 08-29-2013 10:54 AM
Is there a way to force it to do afp / smb. It works when i ssh into the machine.
Posted on 08-29-2013 10:57 AM
Yes! In the policy, or if running it from Casper Remote, use the Override Default Policy Settings option to specify AFP/SMB as the protocol to force over http(s). That might be a good test. If it works that way, then it points directly to an issue with http/s on your distribution point.
Posted on 08-29-2013 11:02 AM
Ok yes the AFP / SMB worked the script finished and i was able to push it out to my test machine. I was using casper remote to do the testing.
Now to re-image the machine and set it up as a test machine again to see about creating a policy in JSS it self.
Posted on 08-29-2013 11:06 AM
So there is something up with your HTTP/s settings for your distribution point.
There's an article on this: https://jamfnation.jamfsoftware.com/article.html?id=116.
Give that a go.
Posted on 08-29-2013 11:12 AM
Thanks bentoms ill take a look, we just finished our jump start 2 weeks ago and it was working so i would surprised if it is not working now.
Posted on 09-05-2013 06:49 AM
Ok so they are not being prompted for a password when they add a printer but the computers are trying to download a update or the computer is trying to install the print driver and its prompting them for a password still. If any of you have seen this and know a way to fix please let me know.
Thanks.
Posted on 09-05-2013 09:05 AM
Deploy the printer drivers from Apple for the models of printers you use. For the major manufacturers (HP, Canon, Epson, Xerox), the drivers are available for download from Apple's Support website:
http://support.apple.com/downloads#hp will show you HP drivers
http://support.apple.com/downloads#xerox will show you Xerox drivers
Could either make this available as part of your image, deploy them via policies, or make them available through Self Service.
Casper handles printer deployment very well, and you can make printers available via Self Service. Great advantage is that users don't have to be lpadmins, and you can be sure they've set up the printer correctly...