Solved

IBM iseries i5 php system command

Posted on 2009-07-08
3
944 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

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 35

Expert Comment

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

- Gary Patterson
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

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