What is the difference between a command, function and systemcall?
This is probably homework help, but anyhow:
Command - A program (or a shell built-in) you execute from (probably) your command shell.
Function - A logical subset of your program. Calling one is entirely within your process.
Systemcall - A function that is executed by your operating system; a primary way of using OS features like working with a file system or using the network.
A command can be a program, which in turn is comprised of functions, which themselves can execute system calls.
For example, the 'cp' command in Unix-like systems copies files. Its implementation includes functions which perform the copying. Those functions themselves execute system-calls like open() and read().
They are all just abstractions of a set of computer instructions which perform a given task.
Related
I see that Origen supports passing jobs to the program command in this video. What would be the preferred method to run the program command in a job loop (i.e. job == 'ws' then job == 'ft', etc.).
thx
The job is a runtime concept, not a compile/generate time concept, so it doesn't really make sense to run the program command (i.e. generate the program) against different settings of job.
Origen doesn't currently provide any mechanism to pass define-type arguments through to the program generator from the command line, though you could implement that in your app easily enough by overriding the program command - i.e. capture and store them somewhere in your app and then continue with the regular command.
The 'Origen-way' of doing things like this is to setup different target files with different variables set within them, then execute the program command for the different targets.
Bash functions are more versatile than aliases. For example, they accept parameters.
Is there any drawback to going full function style and completely drop aliases, even for simple cases? I can imagine that maybe functions are more resource intensive, but have no data to back that up.
Any other reason to keep some of my aliases? They have easier syntax and are easier for humans to read, but apart from that?
Note: aliases take precedence over functions.
Following link may be relevant regarding function overhead, it seems there is no overhead comparing to alias: 3.6. Functions, Aliases, and the Environment
Quoting Dan again: "Shell functions are about as efficient as they can be. It is the approximate equivalent of sourcing a bash/bourne shell script save that no file I/O need be done as the function is already in memory. The shell functions are typically loaded from [.bashrc or .bash_profile] depending on whether you want them only in the initial shell or in subshells as well. Contrast this with running a shell script: Your shell forks, the child does an exec, potentially the path is searched, the kernel opens the file and examines enough bytes to determine how to run the file, in the case of a shell script a shell must be started with the name of the script as its argument, the shell then opens the file, reads it and executes the statements. Compared to a shell function, everything other than executing the statements can be considered unnecessary overhead."
I am trying to build a python GUI app which needs to run bash scripts and capture their output. Most of the commands used in these scripts require further inputs at run time, as they deal with network and remote systems.
Python's subprocess module allows one to easily run external programs, while providing various options for convenience and customizability.
To run simple programs that do not require interaction, the functions call(), check_call(), and check_output() (omitting arguments) are very useful.
For more complex use cases, where interaction with the running program is required, Popen Objects can be used, where you can customize input/output pipes, as well as many other options - the aformentioned functions are wrappers around these objects. You can interact with a running process through the provided methods poll(), wait(), communicate(), etc.
As well, if communicate() doesn't work for your use case, you can get the file descriptors of the PIPEs via Popen.stdin, Popen.stdout, and Popen.stderr, and interact with them directly with select. I prefer Polling Objects :)
When a shell (e.g. bash) invokes an executable file, it first fork itself, and then its copy execve the executable file.
When a shell invokes builtin commands, there is no new process created, and execve can only operate on executable files while builtin commands are not stored in executable files.
So how are builtin commands stored, and how are they invoked in terms of system calls?
"builtin command" means that you don't have to run an external program. So, no, there's no execve involved at all, and no, there's not even any system call necessarily involved. Your shell really just parses a command string and sees "hey, that's a builtin command, let's execute this and that function".
You can imagine they are the same as shell functions.
So instead of launching external process the shell invokes some internal function library function which reads the input outputs the result and does pretty much the same as main function of regular program.
The shell process itself just handles the builtin and potentially modifies itself or its environment as a result. There might not be any system calls made at all.
I am looking for the JCL equivalent of NEWCOPY method in CEMT/CICS:
CEMT SET PROG(xxxx) NEWCOPY
Any help would be appreciated.
If your answer to NealB's question is "Yes," then here are some options.
Invoke CEMT via an operator command. One way to do this is to run
SDSF in batch, another is to use the TSO CONSOLE command. Be
advised that this requires authorization.
Write a program in your preferred programming language and invoke the
CICS System Programming API SET PROGRAM. Then write another
program, to be executed in batch, that uses the External CICS
Interface (EXCI) to invoke your CICS program that does the SET
PROGRAM.
There exist third-party tools that do what you want, DADS
PLUS is one. We use a facility built into our change management
system, Change Man from Serena. There are likely others.
You can just use the JCL COMMAND to embed the COMMAND in your job stream:
//CMD1 COMMAND 'F CICSRGN1, CEMT SET PROG(xxx) NEWCOPY'
I'm not sure of the syntax, but it is exactly what you would use from an opperator terminal.