Solved

IBM iseries i5 php system command

Posted on 2009-07-08
3
928 Views
Last Modified: 2013-12-13
I am running PHP on an IBM iSeries i5 machine.  From within a PHP script I am trying to issue the "system()" command.  As far as I can tell nothing is happening.  I have tried "system()", "exec()", "shell_exec()" but nothing works.  Can someone point me in the right direction?  Thank you!
system("SNDMSG MSG('this is a test 2') TOUSR(RCRIST)");

Open in new window

0
Comment
Question by:richard_crist
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
Gary Patterson earned 500 total points
ID: 24806052
I'm not a PHP expert, but maybe this will get you going in the right direction:

PHP runs in the PASE environement.  I assume this means that if you use system(), exec(), shell_exec(), etc, you probaby need to use PASE commands and not native (OS/400) commands.  The PASE "system" command is used to run OS/400 commands from a PASE session.

CALL QP2TERM   /* Starts a PASE terminal session */
system 'SNDMSG MSG('this is a test 2') TOUSR(RCRIST)'

Will allow you run the SNDMSG command from PASE.  The full path to "system" is /QOpenSys/usr/bin/system, so if you need to specify a path:

/QOpenSys/usr/bin/system 'SNDMSG MSG('this is a test 2') TOUSR(RCRIST)'

should do it.

You'll have to figure out how to get it quoted properly, I suspect.

This redbook has some info and examples on getting started with PHP on AS/400:

http://www.redbooks.ibm.com/redpapers/pdfs/redp3639.pdf

- Gary Patterson
0
 
LVL 3

Author Closing Comment

by:richard_crist
ID: 31601182
You are a Guru!  No...really.   :)

Thanks, Gary, for your help on this and other stuff in the past!  Your idea worked great!  Below is what I ended up doing:

  $cmd = "/QOpenSys/usr/bin/system \"SNDMSG  MSG('hello 5') TOUSR(RCRIST)\"";
  system($cmd);
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 24808694
Happy I could help.

- Gary Patterson
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Windows 10 is here and for most admins this means frustration and challenges getting that first working Windows 10 image. As in my previous sysprep articles, I've put together a simple help guide to get you through this process. The aim is to achiev…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now