How to submit a JCL through SQR Call System Command on MVS z/os? - zos

I’m trying to submit a JCL through an SQR Program using Call System Command on MVS z/os. The JCL resides in specific Dataset.
What I’m trying do is something like this:
let $jclcmd= 'SUBMIT PSLIBDSN.O92.CUST7.JCLSRC(UTILI)'
call system using $jclcmd #rtnstat
Up to this point, I have not been able to submit the JCL. What I get from the mainframe is this error:
**** WARNING **** ERRNO = ESYS
Generated in SYSTEM called from line 389 of SYS(UCALL) , offset 000118
Program SUBMIT was abnormally terminated with a system code of 66D.SYS(UCALL) , offset 000118
I also tried let $jclcmd= 'TSO SUBMIT PSLIBDSN.O92.CUST7.JCLSRC(UTILI)' but gets this:
Program TSO was abnormally terminated with a system code of 806.
SYSTEM COMPLETION CODE=806 REASON CODE=00000004
Up to this point I have thought that the call system function does not allow operating system commands to be executed for reasons of incompatibility with MVS. The reality is that the SQR documentation does not mention that it is not, but always mentions Windows and UNIX as an example. I have made a thousand attempts to execute a REXX program, submit a JCL and others but looks like the function is not right assembling the command.
Any idea will be welcome.

Related

python Gtk app failed with this error xcb xlib threads sequence lost failed

I had a pyGObject app and I run that. all things work fine until on a button clicked signal I need to run a def. it has a long loop and I run that with the
def on_launch_btn_clicked(self,button):
_thread.start_new_thread(launch,["thread"])
def launch(thread):
lines_list = open("../line.txt").split()
for line in lines_list:
select = machinestate.objects.get(id=1)
if not select.pause:
#my process
else:
def pause_lcd()
return "pause" #it for come out of def and close thread but I don't know it close that or not
this loop is in another .py file
function it works like a charm, next I had a pause button it changes database pause field to True and my loop every iteration check database to saw what is changed. when it saw pause is True it run
def pause_lcd():
app = app_list[0]
app.pause_action()
I run Gtk app in this def
app_list = list()
def main(thread):
app = GUI()
app_list.append(app)
Gdk.threads_init()
Gtk.main()
in my GUI class I have pause_action method
def pause_action(self):
self.pause_btn.set_sensitive(True)
self.pause_btn.hide()
self.resume_btn.show()
when I clicked on pause button some time I got this error
[xcb] Unknown sequence number while processing queen
[xcb] Most likely this is a mulity-threaded client and XinitThreads has not been called
[xcb] Aborting, sorry about that
pyhton: ../../src/xcb_io.c:263 poll_for_event: Assertion '!xcb_xlib_threads_sequence_lost failed.
I had a bunch of thread side this threads like machine info, clock, machine temp and ...
what I do wrongs??
PS: this app run in a Django project and I use Django model in this it is an app of Django but it runs a Gtk app
I suspect that something with the XCB or the X11 server is wrong (bug). I received the same error message from different applications on a specific X server (using X11 over ssh).
Error message with emacs:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
emacs: xcb_io.c:263: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Error message with eclipse:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
java: xcb_io.c:263: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.

How can I detach process from Elixir System.cmd/2 before command ends?

I'm trying to run this (script.exs):
System.cmd("zsh", ["-c" "com.spotify.Client"])
IO.puts("done.")
Spotify opens, but "done." never shows up on the screen. I also tried:
System.cmd("zsh", ["-c" "nohup com.spotify.Client &"])
IO.puts("done.")
My script only halts when I close the spotify window. Is it possible to run commands without waiting for it to end?
One should not spawn system tasks in a blind hope they would work properly. If the system task crashes, some actions should be taken in the calling OTP process, otherwise sooner or later it’ll crash in production and nobody would know what had happened and why.
There are many possible scenarios, I would go with Task.start_link/1 (assuming the calling process traps exits,) or with Task.async/1 accompanied by an explicit Task.await/1 somewhere in the supervision tree.
If despite everything explained above you don’t care about robustness, use Kernel.spawn/1 like below
pid = spawn(System, :cmd, ~w|zsh -c com.spotify.Client|)
# Process.monitor(pid) # yet give it a chance to handle errors
IO.puts("done.")

Stop VFP from showing dialog boxes when errors occur

I am trying to call an existing VFP 6 application using Jacob which is a COM bridge for Java.
val vfp = new Application(new ActiveXComponent("VisualFoxPro.Application").getProperty("Application").toDispatch())
vfp.setVisible(false)
try {
vfp.doCmd("do my.exe with myconfig.txt")
} catch {
case t: Throwable => t.printStackTrace
} finally {
vfp.doCmd("close data")
vfp.doCmd("clear all")
vfp.doCmd("clear")
vfp.quit
vfp.safeRelease
}
When there are no error conditions this code executes well and generates the expected .dbfs. The problem is that when an error occurs (.dbf not found, file in use by another user, etc) a GUI window pops up and stops execution of the program until I use the mouse to cancel it. I want this program to run on a server with no user interaction so this won't work.
How can I gracefully handle the errors preferably without making a change to the VFP 6 program?
Since you have the source code for VFP6, I would suggest looking into
SYS(2335,0)
Sys 2335 is used to identify if the program is running in an "unattended" mode, any such popup dialog boxes will throw an error and prevent an actual "hit" ok/cancel/whatever button to continue. This includes popup window prompting user to pick a table.
I'm not positive of when it was made available as I had limited use of it. Like you, when dealing with a COM server under IIS and obviously nobody there to respond.
Start JVM in headless mode, catch HeadlessException or something. Or, write a Java program that will execute your GUI program using Runtime, and restart in a case of parsed errors in console.

How do I send message from the command line to an Erlang process?

I am trying to notify an Erlang process that an external program (a Matlab script) has completed. I am using a batch file to do this and would like to enter a command that will notify the Erlang process of completion. Here is the main code:
In myerlangprogram.erl:
runmatlab() ->
receive
updatemodel->
os:cmd("matlabscript.bat"),
...
end.
In matlabscript.bat:
matlab -nosplash -nodesktop -r "addpath('C:/mypath/'); mymatlabscript; %quit;"
%% I would like to notify erlang of completion here....
exit
As you can see I am using the 'os:cmd' erlang function to call my matlab script.
I am not sure that this is the best approach. I have been looking into using ports (http://www.erlang.org/doc/reference_manual/ports.html) but am struggling to understand how/where the ports interact with the operating system.
In summary, my 2 questions are:
1. What is the easiest way to send a message to an Erlang process from the command line?
2. Where/how do erlang ports receive/send data from/to the operating system?
Any advice on this would be gratefully received.
N.b. the operating system is windows 7.
I assume that you want to call os:cmd without blocking your main process loop. In order to accomplish that you will need to call os:command from a spawned process and then send a message back to the Parent process indicating completion.
Here is an example:
runmatlab() ->
receive
updatemodel ->
Parent = self(),
spawn_link(fun() ->
Response = os:cmd("matlabscript.bat"),
Parent ! {updatedmodel, Response}
end),
runmatlab();
{updatedmodel, Response} ->
% do something with response
runmatlab()
end.
For the first, Erlang process is something definitely different from os process. There is no "notifications" mechanism or "messaging" mechanism between them. What can you do is a) run new erlang node, b) connect to target node, c) send message to remote node.
But. Regarding to your question.
runmatlab() ->
receive
updatemodel->
BatOutput = os:cmd("matlabscript.bat"),
%% "here" BAT script has already finished
%% and output can be found in BatOutput variable
...
end.
For the second, ports are about encoding/decoding erlang data type (in short words).

Output to command-line if started from command line

I'm writing an application that can be started either as a standard WinForms app or in unattended mode from the command-line. The application was built using the VS 2k5 standard WinForms template.
When the application is executed from the command-line, I want it to output information that can be captured by the script executing the application. When I do this directly from Console.WriteLine(), the output does not appear, although it can be captured by piping to a file.
On the other hand, I can force the application to pop up a second console by doing a P/Invoke on AllocConsole() from kernel32. This is not what I want, though. I want the output to appear in the same window the application was called from.
This is the salient code that allows me to pop up a console from the command line:
<STAThread()> Public Shared Sub Main()
If My.Application.CommandLineArgs.Count = 0 Then
Dim frm As New ISECMMParamUtilForm()
frm.ShowDialog()
Else
Try
ConsoleControl.AllocConsole()
Dim exMan As New UnattendedExecutionManager(ConvertArgs())
IsInConsoleMode = True
OutputMessage("Application started.")
If Not exMan.SetSettings() Then
OutputMessage("Execution failed.")
End If
Catch ex As Exception
Console.WriteLine(ex.ToString())
Finally
ConsoleControl.FreeConsole()
End Try
End If
End Sub
Public Shared Sub OutputMessage(ByVal msg As String, Optional ByVal isError As Boolean = False)
Trace.WriteLine(msg)
If IsInConsoleMode Then
Console.WriteLine(msg)
End If
If isError Then
EventLog.WriteEntry("ISE CMM Param Util", msg, EventLogEntryType.Error)
Else
EventLog.WriteEntry("ISE CMM Param Util", msg, EventLogEntryType.Information)
End If
End Sub
Raymond Chen recently posted (a month after the question was posted here on SO) a short article about this:
How do I write a program that can be run either as a console or a GUI application?
You can't, but you can try to fake it.
Each PE application contains a field
in its header that specifies which
subsystem it was designed to run
under. You can say
IMAGE_SUBSYSTEM_WINDOWS_GUI to mark
yourself as a Windows GUI application,
or you can say
IMAGE_SUBSYSTEM_WINDOWS_CUI to say
that you are a console application. If
you are GUI application, then the
program will run without a console.
The subsystem determines how the
kernel prepares the execution
environment for the program. If the
program is marked as running in the
console subsystem, then the kernel
will connect the program's console to
the console of its parent, creating a
new console if the parent doesn't have
a console. (This is an incomplete
description, but the details aren't
relevant to the discussion.) On the
other hand, if the program is marked
as running as a GUI application, then
the kernel will run the program
without any console at all.
In that article he points to another by Junfeng Zhang that discusses how a couple of programs (Visual Studio and ildasm) implement this behavior:
How to make an application as both GUI and Console application?
In VisualStudio case, there are actually two binaries: devenv.com and devenv.exe. Devenv.com is a Console app. Devenv.exe is a GUI app. When you type devenv, because of the Win32 probing rule, devenv.com is executed. If there is no input, devenv.com launches devenv.exe, and exits itself. If there are inputs, devenv.com handles them as normal Console app.
In ildasm case, there is only one binary: ildasm.exe. It is first compiled as a GUI application. Later editbin.exe is used to mark it as console subsystem. In its main method it determines if it needs to be run as console mode or GUI mode. If need to run as GUI mode, it relaunches itself as a GUI app.
In the comments to Raymond Chen's article, laonianren has this to add to Junfeng Zhang's brief description of how Visual Studio works:
devenv.com is a general purpose console-mode stub application. When it runs it creates three pipes to redirect the console's stdin, stdout and stderr. It then finds its own name (usually devenv.com), replaces the ".com" with ".exe" and launches the new app (i.e. devenv.exe) using the read end of the stdin pipe and the write ends of the stdout and stderr pipes as the standard handles. Then it just sits and waits for devenv.exe to exit and copies data between the console and the pipes.
Thus even though devenv.exe is a gui app it can read and write the "parent" console using its standard handles.
And you could use devenv.com yourself for myapp.exe by renaming it to myapp.com. But you can't in practise because it belongs to MS.
Update 1:
As said in Michael Burr answer, Raymond Chen recently posted a short article about this. I am happy to see that my guess was not totally wrong.
Update 0:
Disclaimer: This "answer" is mostly speculation. I post it only because enough time has passed to establish that not many people have the answer to what look like a fundamental question.
I think that the "decision" if the application is gui or console is made at compile time and not at runtime. So if you compile your application as gui application, even if you don't display the gui, its still a gui application and doesn't have console. If you choose to compile it as console application then at minimum you will have a console windows flashing before moving to gui "mode". And I don't know if it is possible in managed code.
The problem is fundamental, I think, Because a console application has to take "control" of the calling console application. And it has to do so before the code of the child application is running.
If you want to check if your app is started from the command line in .NET, you can use Console.GetCursorPosition().
The reason that this works is that when you start it from the command line, the cursor moves away from the initial point ((0, 0)) because you typed something in the terminal (the name of the app).
You can do this with an equality check (code in C#):
class Program
{
public static void Main
{
if (Console.GetCursorPosition() == (0, 0))
{
//something GUI
}
else
{
//something not GUI
}
}
}
Note: You must set the output type to Console Application as other output types will make Console.GetCursorPosition() throw an exception.