my setup is 2 ser servers & 1 mysql server. i want to look up a user in table "location" to see if one of the two ser servers registered the user, so i've decided to follow the example in the admin guide and use exec_dset(). however, i'm getting an error output. anyone knows what's wrong with the following?
if ( !exec_dset( 'QUERY="select contact from location where username="$SIP_OUSER""; DEST_URI=`mysql -user -pheslo -h10.1.201.107 -Bs -e"$QUERY" ser`; if [ -z "$DEST_URI" ] then exit 1 fi; echo "$DEST_URI"; echo > /dev/null;' ) ) { xlog("L_INFO", "\n\n%ru is not online (in db)\n"); sl_send_reply( "404", "User does not exist" ); break; };
the error output is:
sh: -c: line 4: syntax error: unexpected end of file 12(14932) ERROR:exec_str: no uri from QUERY="select contact from location where username="$SIP_OUSER""; DEST_URI=`mysql -user -pheslo -h10.1.201.107 -Bs -e"$QUERY" ser`; if [ -z "$DEST_URI" ] then exit 1 fi; echo "$DEST_URI"; echo > /dev/null; sip:12222220002@10.1.201.191 12(14932)
i'm not sure why 'sip:12222220002@10.1.201.191' is there, but i think that might be part of the problem. when i tried the following:
if ( !exec_dset( 'echo sip:12222220002@10.1.201.65; echo > /dev/null' ) )
it works fine.
Jack Wei
__________________________________ Yahoo! Mail Mobile Take Yahoo! Mail with you! Check email on your mobile phone. http://mobile.yahoo.com/learn/mail
Querying mysql using exec_dset is messy and takes a lot of resources. However, to keep it clean I'd do this in an external script. Something like:
#!/bin/sh user=`/bin/echo $1 | /bin/awk -F'@' '{print $1}' | /bin/awk -F':' '{print $2}'` query="select contact from location where username="$user";" mysql -user -pheslo -h10.1.201.107 -Bs -e "$query" ser
Then in your ser.cfg just do: exec_dset("/path/to/script.sh"); and make sure it's chmod'd 0755. The reason that the docs all recommend using ;echo >/dev/null as the last part of exec_dset is because the command passes the RURI as the argument, so in the command above it would actually get called as "/path/to/script.sh sip:12222220002@10.1.201.191" so you can see how the awk command in the above script pulls the username out. Also if you're going to use this make sure your db_mode is set to 1 (write through) so that changes to the usrloc tables are made immediately. Note that this doesn't handle domains so if you have user1@domain1.tld and user1@domain2.tld this snippet wont work.
Check back through the mailing list for the carrier-grade framework discussion. SER in it's current incarnation (especially 0.8) doesn't deal well with a active-active setup, that discussion talks about a bunch of different ideas on how to handle this situation.
-Evan
Jack Wei wrote:
my setup is 2 ser servers & 1 mysql server. i want to look up a user in table "location" to see if one of the two ser servers registered the user, so i've decided to follow the example in the admin guide and use exec_dset(). however, i'm getting an error output. anyone knows what's wrong with the following?
if ( !exec_dset( 'QUERY="select contact from location where
username="$SIP_OUSER""; DEST_URI=`mysql -user -pheslo -h10.1.201.107 -Bs -e"$QUERY" ser`; if [ -z "$DEST_URI" ] then exit 1 fi; echo "$DEST_URI"; echo > /dev/null;' ) ) { xlog("L_INFO", "\n\n%ru is not online (in db)\n"); sl_send_reply( "404", "User does not exist" ); break; };
the error output is:
sh: -c: line 4: syntax error: unexpected end of file 12(14932) ERROR:exec_str: no uri from QUERY="select contact from location where username="$SIP_OUSER""; DEST_URI=`mysql -user -pheslo -h10.1.201.107 -Bs -e"$QUERY" ser`; if [ -z "$DEST_URI" ] then exit 1 fi; echo "$DEST_URI"; echo > /dev/null; sip:12222220002@10.1.201.191 12(14932)
i'm not sure why 'sip:12222220002@10.1.201.191' is there, but i think that might be part of the problem. when i tried the following:
if ( !exec_dset( 'echo sip:12222220002@10.1.201.65; echo > /dev/null' ) )
it works fine.
Jack Wei
__________________________________ Yahoo! Mail Mobile Take Yahoo! Mail with you! Check email on your mobile phone. http://mobile.yahoo.com/learn/mail
Serusers mailing list serusers@lists.iptel.org http://lists.iptel.org/mailman/listinfo/serusers
You could use t_replicte to keep the current location data in both ser's. Then, lookup("location") works. (except if the clients are behind NAT).
regards, klaus
Jack Wei wrote:
my setup is 2 ser servers & 1 mysql server. i want to look up a user in table "location" to see if one of the two ser servers registered the user, so i've decided to follow the example in the admin guide and use exec_dset(). however, i'm getting an error output. anyone knows what's wrong with the following?
if ( !exec_dset( 'QUERY="select contact from location where
username="$SIP_OUSER""; DEST_URI=`mysql -user -pheslo -h10.1.201.107 -Bs -e"$QUERY" ser`; if [ -z "$DEST_URI" ] then exit 1 fi; echo "$DEST_URI"; echo > /dev/null;' ) ) { xlog("L_INFO", "\n\n%ru is not online (in db)\n"); sl_send_reply( "404", "User does not exist" ); break; };
the error output is:
sh: -c: line 4: syntax error: unexpected end of file 12(14932) ERROR:exec_str: no uri from QUERY="select contact from location where username="$SIP_OUSER""; DEST_URI=`mysql -user -pheslo -h10.1.201.107 -Bs -e"$QUERY" ser`; if [ -z "$DEST_URI" ] then exit 1 fi; echo "$DEST_URI"; echo > /dev/null; sip:12222220002@10.1.201.191 12(14932)
i'm not sure why 'sip:12222220002@10.1.201.191' is there, but i think that might be part of the problem. when i tried the following:
if ( !exec_dset( 'echo sip:12222220002@10.1.201.65; echo > /dev/null' ) )
it works fine.
Jack Wei
__________________________________ Yahoo! Mail Mobile Take Yahoo! Mail with you! Check email on your mobile phone. http://mobile.yahoo.com/learn/mail
Serusers mailing list serusers@lists.iptel.org http://lists.iptel.org/mailman/listinfo/serusers