ben wrote:
> Hello,
> 
> I'm trying to communicate with sage using PHP. I want it to calculate
> 1+2. I've written this little bash script:
> 
> #!/bin/bash
> cd /usr/local/sage-3.2.1
> ./sage  -q << END
> 1+2
> END
> read -p "Press enter to continue"
> 
> which outputs:
> 
> sage: 3
> sage:
> Exiting SAGE (CPU time 0m0.04s, Wall time 0m0.04s).
> Press enter to continue
> 
> however, when I execute the script from PHP using this:
> 
> echo exec("cd /home/ben/Desktop && ./test.sh",$out);
> print_r($out);
> 
> it outputs:
> 
>  
> **********************************************************************
> Welcome to IPython. I will try to create a personal configuration
> directory  where you can customize many aspects of IPython's
> functionality in: /root/.sage/ipython  Initializing from
> configuration /usr/local/sage-3.2.1/local/lib/python2.5/site-packages/
> IPython/UserConfig Please press  to start
> IPython.**********************************************************************
> Press enter to exit:
> 
> why do I not get the same output as when I execute the script
> directly? is there any way stopping the welcome message being output
> every time? how can I get the answer 3?


It looks like sage is being run as a different user when you are using 
php (as root user!).  First, I would be extremely careful when running 
Sage this way; there are lots of obvious and subtle security implications.

That said, you can probably get the configuration messages over with by 
just running Sage once as the user in question (again, it looks like root).

I would highly recommend not running Sage as root (as appears to be done 
above) unless you know exactly what you are doing.

Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to