Jump to content


Photo
- - - - -

Executing SYSTEM and SYSTEM-CRT


15 replies to this topic

#1 gmejia

gmejia

    Newbie

  • Members
  • Pip
  • 9 posts
  • Gender:Male

Posted 04 July 2006 - 12:45 AM

Hi all !

I am have a problem (maybe a very dumb problem) using SYSTEM command, I am trying to execute a simple script with this:

#x = SYSTEM(" UNIX COMMAND")

I tried with a simple "ls" command, but when I run it appears a telnet window with a line on the top and nothing happend, I have to stop it closing my proiv session. I hope some one could help me !

We are using ProIV 4.6 and Linux RedHat 7.2

Thanks in advance.

Gustavo Mejia
SolSoft Mexico.

#2 Vol Yip

Vol Yip

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 393 posts
  • Gender:Male
  • Location:Hong Kong

Posted 04 July 2006 - 01:21 AM

I guess the problem is that when you do #X = SYSTEM("ls"), PRO-IV already output the ls result without stops at the end and let you view the result.

You can try the follwoing

#X = SYSTEM("ls > result.txt")

and then go to the folder and find out if result.txt has been created and view the result there.

#3 Mike Schoen

Mike Schoen

    Expert

  • Members
  • PipPipPipPip
  • 198 posts
  • Gender:Male
  • Location:Guelph, Canada

Posted 04 July 2006 - 01:05 PM

Whenever you do system commands under *nix, if there is any screen output at all (standard output or error output) pro-iv will bring the telnet window to the foreground, and leave it visible on the screen for the duration of the pro-iv session.

You can still switch back to proiv.exe but the window will still be there.

We always redirect output when doing system calls, like this:

#I = SYSTEM('ls -l > ls.txt 2>/dev/null')

The 2>/dev/null redirects any errors to the null device, so that users dont see them, and the telnet window does not open.

#4 gmejia

gmejia

    Newbie

  • Members
  • Pip
  • 9 posts
  • Gender:Male

Posted 04 July 2006 - 07:27 PM

Thanks... but the command with "ls" was just an example, I already have my own script and I want to run it, but happens the same.

#5 Vol Yip

Vol Yip

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 393 posts
  • Gender:Male
  • Location:Hong Kong

Posted 04 July 2006 - 11:32 PM

What happens when you run #I = SYSTEM('ls -l > ls.txt 2>/dev/null') then?

Does the system generate the ls.txt file?

Edited by Vol Yip, 04 July 2006 - 11:32 PM.


#6 gmejia

gmejia

    Newbie

  • Members
  • Pip
  • 9 posts
  • Gender:Male

Posted 05 July 2006 - 01:17 PM

Nothing happend, just start the telnet window and seems to be in stand by, and I can close this window just when I close de Pro-iv session.

#7 Joseph Bove

Joseph Bove

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 756 posts
  • Gender:Male
  • Location:Ramsey, United States

Posted 05 July 2006 - 01:26 PM

gmejia,

Nothing happend, just start the telnet window and seems to be in stand by, and I can close this window just when I close de Pro-iv session.


Is your script waiting for input at all?

Also did the standard out and standard error files show anything?

Regards,

Joseph

#8 gmejia

gmejia

    Newbie

  • Members
  • Pip
  • 9 posts
  • Gender:Male

Posted 05 July 2006 - 10:10 PM

I execute from the Pro-iv command promp !ksh and there my script, and it works fine.

with the application nothing happends, there is nothing in the error files.

#9 Chris Pepper

Chris Pepper

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 369 posts
  • Gender:Male
  • Location:United Kingdom

Posted 06 July 2006 - 07:44 AM

If you are running !ksh then you are specifically invoking the Korn shell.

I don't know what you have in the SYSTEM command, but does this invoke the Korn shell too?

Just a thought...

#10 gmejia

gmejia

    Newbie

  • Members
  • Pip
  • 9 posts
  • Gender:Male

Posted 06 July 2006 - 12:03 PM

I have something like

#X = SYSTEM("myScript.sh parameter1 parameter2")

and in my script I am calling a java class who reads a data base and writes a file, but I am trying with other unix commands, like "ls" and it is the same.

#11 Mike Schoen

Mike Schoen

    Expert

  • Members
  • PipPipPipPip
  • 198 posts
  • Gender:Male
  • Location:Guelph, Canada

Posted 06 July 2006 - 12:42 PM

Try adding #!/bin/ksh at the beginning of the script.
Pro-iv uses /bin/sh by default when you execute system commands, which may be failing on ksh-specific syntax.
Also, try specifying the full pathname to your script, and changing it to do something simple, like this:

touch /tmp/script_ran_ok
exit

this will at least tell you if the script is getting executed or not.

#12 gmejia

gmejia

    Newbie

  • Members
  • Pip
  • 9 posts
  • Gender:Male

Posted 06 July 2006 - 01:31 PM

Thanks.. but it didn't work... It seems that Pro-IV is not invoking in the correct way, or it is not sending the instruction

#13 Chris Mackenzie

Chris Mackenzie

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 368 posts
  • Gender:Male
  • Location:Bristol, United Kingdom

Posted 06 July 2006 - 02:21 PM

Today I found there are certain kernel configurations
that prevent/fail to spawn a subshell, using !sh .
Don't think it stops SYSTEM from working though.

But if you can't fix this issue because of your environment
you could replace your script with a c program and link
it into extsub.c then use P4 LINK verb instead of SYSTEM
The content and views expressed in this message are those
of the poster and do not represent those of any organisation.

#14 Guest_rpolitiek_*

Guest_rpolitiek_*
  • Guests

Posted 18 September 2007 - 07:00 AM

I'm picking up this thread again, because I read no final awnser to the original problem.
The original problem is that a SYSTEM call to a script does not work in Linux, at least not in my configuration; i.e 5.0 under Red Hat 7.x
I encounter the same problem as the originator of this thread.
With a 'simple' SYSTEM call (#S = SYSTEM('path' + 'script')) I am trying to invoke a script for a specific job.
* a UMSG on #S gives 0 for the STATUS.
* replacing SYSTEM by SYSTEM-CRT does not make a difference.
* the script itself works and has enough (=maximum) rights to be processed. If I initiate it outside pro-iv it does its job.

Must we conclude that the SYSTEM command does not work fully under linux, at least not in this version of P4??
Or am I doing something completely wrong??

#15 DARREN

DARREN

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 395 posts
  • Gender:Male
  • Location:Florida,USA

Posted 18 September 2007 - 03:02 PM

I'm picking up this thread again, because I read no final awnser to the original problem.
The original problem is that a SYSTEM call to a script does not work in Linux, at least not in my configuration; i.e 5.0 under Red Hat 7.x
I encounter the same problem as the originator of this thread.
With a 'simple' SYSTEM call (#S = SYSTEM('path' + 'script')) I am trying to invoke a script for a specific job.
* a UMSG on #S gives 0 for the STATUS.
* replacing SYSTEM by SYSTEM-CRT does not make a difference.
* the script itself works and has enough (=maximum) rights to be processed. If I initiate it outside pro-iv it does its job.

Must we conclude that the SYSTEM command does not work fully under linux, at least not in this version of P4??
Or am I doing something completely wrong??


This works for us.

$$COMMAND = 'acscopy.sh ' + &$@~PRODATA + '/stat/' + RM_COM_STATEMENT_FILENAME
//
// Define the command and send the standard output to the null device.
//
$$COMMAND = $$COMMAND + ' ' + ' 2> /dev/null'
#SYSTEM = SYSTEM($$COMMAND)
//
EODEXIT(1)

we are on Kernel Version 5.5000, Revision 5.1.7
uname -a gives Linux 2.4.9-e.57smp #1 SMP
Things should be made as simple as possible, but not simpler



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users