0

I am having trouble running this in my bash script, hopefully someone can help me write the correct line of code:

#!/bin/bash

user=testadmin
pass=123456!@
cu=$(logname)

echo $cu 

curl https://cooke.jamfcloud.com/JSSResource/ldapservers/id/1/user/"$cu" --user "$user:$pass"

Unfortunately I get this in the terminal when I execute the script:

<?xml version="1.0" encoding="UTF-8"?><ldap_users><size>0</size></ldap_users>

Any help would be appreciated, I am new and I made a previous post and some of the people in the community criticized more than helping. Thank you in advance for your support.

  • variables will not get interpolated if they are used inside single quotes. meaning `$cu` will not expand. – P.... Jan 25 '21 at 21:01
  • And that's not how you set a variable to the output of a command. – Barmar Jan 25 '21 at 21:01
  • Can someone show me an example of how I should be writing it please? – Imanuel Agard Jan 25 '21 at 21:12
  • Hey I appreciate you all telling me that I did something wrong but if someone could give me an example of what I should be writing instead of just telling me I am wrong and leaving me up in the air. – Imanuel Agard Jan 25 '21 at 21:21
  • The line `pass=123456!@` should cause an error because the shell will interpret `!@`. If your password really has special characters in it, single quote it: `pass='qwert!@'`. – joanis Mar 04 '21 at 16:54
  • To trouble shoot, I would echo the curl command and see what you get, and try to run that same command interactively. So, `echo curl https://cooke.jamfcloud.com/JSSResource/ldapservers/id/1/user/"$cu" --user "$user:$pass"` will show you what will really get run, and should help you figure out what's wrong. – joanis Mar 04 '21 at 16:58

0 Answers0