Can't execute external command using SYSTEM
Posted in 2007
Paul couldn't run his own compiled C/4GL program from an SPL routine via SYSTEM, getting "-668: System command cannot be executed" plus "2: No such file or directory", while ls and isql worked. Suggestions included using the full path, ensuring the binary is in the server's PATH, and making it executable by user/group informix. The actual cause, found by Paul: his program exited with a non-zero status, which IDS treats as failure, reporting -668 with the exit code shown misleadingly as an ISAM error (a known bug fixed in IDS 10). Making the program return 0 solved it.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Stored Procedures & SPL
Hi guys. I'm trying to use SYSTEM from an SPL routine to execute an external command. It's not an OS command like date, ls, etc.. I can execute date and ls ok, but when I try to execute my compiled C executable, it just won't work either saying "No such file or direcotory" or "668: System command cannot be executed." Does SYSTEM only work with OS commands like date and ls? Paul
No, but the file has to be in the PATH that the server was started with or you'll have to SYSTEM a full path as: SYSTEM("/mybin/mytask"); Also, the task must be executable by user informix or group informix which is how the server processes run. Art S. Kagel ----- Original Message ----- From: Paul Iancu <ids@iiug.org> To: ids@iiug.org At: 9/25 14:39:09 Hi guys. I'm trying to use SYSTEM from an SPL routine to execute an external command. It's not an OS command like date, ls, etc.. I can execute date and ls ok, but when I try to execute my compiled C executable, it just won't work either saying "No such file or direcotory" or "668: System command cannot be executed." Does SYSTEM only work with OS commands like date and ls? Paul ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
One way to do this is to set the ownership and permissions similar to those of the informix software ... Be careful with that though ... "PAUL IANCU" <iancur@cs.pdx.edu> Sent by: ids-bounces@iiug.org 09/25/2007 02:38 PM Please respond to ids@iiug.org To ids@iiug.org cc Subject Can't execute external command using SYSTEM [10000] Hi guys. I'm trying to use SYSTEM from an SPL routine to execute an external command. It's not an OS command like date, ls, etc.. I can execute date and ls ok, but when I try to execute my compiled C executable, it just won't work either saying "No such file or direcotory" or "668: System command cannot be executed." Does SYSTEM only work with OS commands like date and ls? Paul ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
Hello Paul: Did you call the command with the full path name like "/usr/bin/ls" Alex DeWolf UNIX Admin/DBA City Of Chula Vista -----Original Message----- From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org]On Behalf Of PAUL IANCU Sent: Tuesday, September 25, 2007 11:39 AM To: ids@iiug.org Subject: Can't execute external command using SYSTEM [10000] Hi guys. I'm trying to use SYSTEM from an SPL routine to execute an external command. It's not an OS command like date, ls, etc.. I can execute date and ls ok, but when I try to execute my compiled C executable, it just won't work either saying "No such file or direcotory" or "668: System command cannot be executed." Does SYSTEM only work with OS commands like date and ls? Paul ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
No, I just did SYSTEM "ls"
When I try to execute isql from the $INFORMIXDIR/bin directory it
works. When I try to execute cm_info_custom (my executable compiled
using the c4gl compiler), it says no such directory or file. Only difference I
see is that in the second column output from ls -l isql has 5 and my
executable has 1.
These are the files:
-rwxr-xr-x 5 informix informix 1897333 Jul 5 2005 isql*
-rwxr-xr-x 1 informix informix 4222976 Sep 20 16:32 cm_info_custom*
This is the test SPL routine
DROP PROCEDURE update_comments();
CREATE PROCEDURE update_comments()
RETURNING INT;
DEFINE task_id INT;
DEFINE flag INT;
DEFINE command CHAR(300);
LET command = "/opt/infx_9.40fc5_7.30hc7/bin/cm_info_custom";
LET task_id = 12598800;
LET flag = 0;
SYSTEM command;
RETURN 0;
END PROCEDURE;
This is the error:
668: System command cannot be executed.
2: No such file or directory
Haven't read the rest of the thread. (tired).
Did you Connect to the database as a named user w/ passwd? If not, Windows
will certainly kick a 668.
j.
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org]On Behalf Of
PAUL IANCU
Sent: Tuesday, September 25, 2007 6:00 PM
To: ids@iiug.org
Subject: Re: RE: Can't execute external command using S.... [10005]
No, I just did SYSTEM "ls"
When I try to execute isql from the $INFORMIXDIR/bin directory it
works. When I try to execute cm_info_custom (my executable compiled
using the c4gl compiler), it says no such directory or file. Only difference
I
see is that in the second column output from ls -l isql has 5 and my
executable has 1.
These are the files:
-rwxr-xr-x 5 informix informix 1897333 Jul 5 2005 isql*
-rwxr-xr-x 1 informix informix 4222976 Sep 20 16:32 cm_info_custom*
This is the test SPL routine
DROP PROCEDURE update_comments();
CREATE PROCEDURE update_comments()
RETURNING INT;
DEFINE task_id INT;
DEFINE flag INT;
DEFINE command CHAR(300);
LET command = "/opt/infx_9.40fc5_7.30hc7/bin/cm_info_custom";
LET task_id = 12598800;
LET flag = 0;
SYSTEM command;
RETURN 0;
END PROCEDURE;
This is the error:
668: System command cannot be executed.
2: No such file or directory
****************************************************************************
***
Forum Note: Use "Reply" to post a response in the discussion forum.
Thank you to all of you for your help. The problem was that my executable was not returning zero on success. If the executable is not returning 0, Informix will assume the SYSTEM command failed. I did get a bizarre error though (Isam error 2). I stumbled upon this by looking at the bugs fixed in IDS version 10. Here is the bug that was fixed: 176705 WHEN PROGRAM RUN BY SYSTEM STATEMENT EXITS WITH NON-ZERO STATUS, YOU GET SQL ERROR -668 PLUS THE EXIT STATUS AS THE ISAM ERROR - MISLEADING INFO. http://www-1.ibm.com/support/docview.wss?uid=swg27009752