troubleshooting Question

How to run PHP script with session check via linux shell ?

Avatar of Shamsul Kamal
Shamsul Kamal asked on
PHPShell ScriptingLinux
3 Comments1 Solution370 ViewsLast Modified:
Hi,

I would like to request an assistant.

I have the following script :


function getClient() {

    $client = new SoapClient('http://url:8080/SKS1A/SKS1A?wsdl');

    // is soapcookies already set? (must be already logged in)

    if (isset($_SESSION['soapcookies'])) 
          {

        // just set the cookies
        foreach ($_SESSION['soapcookies'] as $cookiename => $value)
            $client->__setCookie($cookiename, $value[0]);
          } 
    else  {

        //please change the username and password

        $result = $client->login(array('username' => $username, 'password' => $password))->return;
        //print_r($result);

        //store the soap cookies in $_SESSION so that don't need to reauthenticate.
        $_SESSION['soapcookies'] = $client->_cookies;
          }

    return $client;
}

$query = "SELECT id,domainname from domain WHERE status='check'";
$data = mysql_query($query, $conn) or die(); 

echo "Cron Check Start<br>";

	while($rec = mysql_fetch_array($data))
	{ 
		
//get the SOAP client connection

$api = getClient();

$domain = $rec[domainname]; 
$arg0 = $reseller;
$arg1 = $domain; //sample result available

$result = $api->checkDomainAvailability(array('arg0' =>$arg0,'arg1' =>$arg1))->return;  
$xml = new SimpleXMLElement($result);
$result = $xml->code; 
$description = $xml->reason;

			if($result == 1000) { echo "Domain $domain successfully checked<br>";		}
					
            else { echo "Domain: '".$rec[domainname]."' '".$description."' ERROR<br>"; }

	}// end while.


May i know how to passed the session check in the script so that i can run the script finely via shell as if using browser ?

The purpose of doing this is that i want to set a cronjob to run this script.

A few complete sample with my current code inside it is appreciated.

Thank you.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros