Advertisement
Guest User

Untitled

a guest
May 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import groovy.sql.Sql
  2. import org.asteriskjava.fastagi.BaseAgiScript
  3. import org.asteriskjava.fastagi.AgiRequest
  4. import org.asteriskjava.fastagi.AgiChannel
  5. import org.asteriskjava.fastagi.AgiException
  6.  
  7.  
  8. public class getserver_ip extends BaseAgiScript
  9. {
  10. public void service(AgiRequest request, AgiChannel channel,Sql sql)
  11. throws AgiException
  12. {
  13. def command = ["sh", "-c", "ifconfig eth0|grep 'inet addr'|cut -d: -f2|awk '{print \$1}'"]
  14. def new1 = command.toArray()
  15. def cmm = Runtime.getRuntime().exec((String[]) new1)
  16. def jf = cmm.in.text
  17. if (jf.length() == 0)
  18. {
  19. println "not found"
  20.  
  21. }
  22. else
  23. {
  24. channel.setVariable("SERVER_IP","${jf}")
  25. println jf
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement