langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -0,0 +1 @@
|
|||
Sys.command "ls"
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#load "unix.cma"
|
||||
|
||||
let syscall cmd =
|
||||
let ic, oc = Unix.open_process cmd in
|
||||
let buf = Buffer.create 16 in
|
||||
(try
|
||||
while true do
|
||||
Buffer.add_channel buf ic 1
|
||||
done
|
||||
with End_of_file -> ());
|
||||
let _ = Unix.close_process (ic, oc) in
|
||||
(Buffer.contents buf)
|
||||
|
||||
let listing = syscall "ls" ;;
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
let check_exit_status = function
|
||||
| Unix.WEXITED 0 -> ()
|
||||
| Unix.WEXITED r -> Printf.eprintf "warning: the process terminated with exit code (%d)\n%!" r
|
||||
| Unix.WSIGNALED n -> Printf.eprintf "warning: the process was killed by a signal (number: %d)\n%!" n
|
||||
| Unix.WSTOPPED n -> Printf.eprintf "warning: the process was stopped by a signal (number: %d)\n%!" n
|
||||
;;
|
||||
|
||||
let syscall ?(env=[| |]) cmd =
|
||||
let ic, oc, ec = Unix.open_process_full cmd env in
|
||||
let buf1 = Buffer.create 96
|
||||
and buf2 = Buffer.create 48 in
|
||||
(try
|
||||
while true do Buffer.add_channel buf1 ic 1 done
|
||||
with End_of_file -> ());
|
||||
(try
|
||||
while true do Buffer.add_channel buf2 ec 1 done
|
||||
with End_of_file -> ());
|
||||
let exit_status = Unix.close_process_full (ic, oc, ec) in
|
||||
check_exit_status exit_status;
|
||||
(Buffer.contents buf1,
|
||||
Buffer.contents buf2)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
void runls()
|
||||
{
|
||||
[[NSTask launchedTaskWithLaunchPath:@"/bin/ls"
|
||||
arguments:[NSArray array]] waitUntilExit];
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
void runSystemCommand(NSString *cmd)
|
||||
{
|
||||
[[NSTask launchedTaskWithLaunchPath:@"/bin/sh"
|
||||
arguments:[NSArray arrayWithObjects:@"-c", cmd, nil]]
|
||||
waitUntilExit];
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
void runSystemCommand(NSString *cmd)
|
||||
{
|
||||
[[NSTask launchedTaskWithLaunchPath:@"/bin/sh"
|
||||
arguments:[NSArray arrayWithObjects:@"-c", cmd, nil]]
|
||||
waitUntilExit];
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [NSAutoreleasePool new];
|
||||
|
||||
runSystemCommand(@"ls");
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
system("ls");
|
||||
|
|
@ -0,0 +1 @@
|
|||
{OS.system "ls" _}
|
||||
|
|
@ -0,0 +1 @@
|
|||
system("ls")
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
Program ExecuteSystemCommand;
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
begin
|
||||
ExecuteProcess('/bin/ls', '-alh');
|
||||
end.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
run "ls" or die $!; # output to stdout
|
||||
|
||||
my @ls = qx/ls/; # output to variable
|
||||
|
||||
my $cmd = 'ls';
|
||||
my @ls = qqx/$ls/; # same thing with interpolation
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
int main(){
|
||||
// Process.run was added in Pike 7.8 as a wrapper to simplify the use of Process.create_process()
|
||||
mapping response = Process.run("ls -l");
|
||||
// response is now a map containing 3 fields
|
||||
// stderr, stdout, and exitcode. We want stdout.
|
||||
write(response["stdout"] + "\n");
|
||||
|
||||
// with older versions of pike it's a bit more complicated:
|
||||
Stdio.File stdout = Stdio.File();
|
||||
Process.create_process(({"ls", "-l"}), ([ "stdout" : stdout->pipe() ]) );
|
||||
write(stdout->read() + "\n");
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
sysobey('ls');
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
dir
|
||||
ls
|
||||
Get-ChildItem
|
||||
|
|
@ -0,0 +1 @@
|
|||
cmd /c dir
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
ImportC "msvcrt.lib"
|
||||
system(str.p-ascii)
|
||||
EndImport
|
||||
|
||||
If OpenConsole()
|
||||
system("dir & pause")
|
||||
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
|
||||
Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
; Capture output to string variable:
|
||||
|
||||
x: "" call/output "dir" x
|
||||
print x
|
||||
|
||||
; The 'console' refinement displays the command output on the REBOL command line.
|
||||
|
||||
call/console "dir *.r"
|
||||
call/console "ls *.r"
|
||||
|
||||
call/console "pause"
|
||||
|
||||
; The 'shell' refinement may be necessary to launch some programs.
|
||||
|
||||
call/shell "notepad.exe"
|
||||
|
|
@ -0,0 +1 @@
|
|||
`ls -la` as listing
|
||||
|
|
@ -0,0 +1 @@
|
|||
'ls -la' shell as listing
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
print shell$("ls") ' prints the returned data from the OS
|
||||
a$ = shell$("ls") ' holds returned data in a$
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "shell.s7i";
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
cmd_sh("ls");
|
||||
end func;
|
||||
|
|
@ -0,0 +1 @@
|
|||
Platform run: 'ls'.
|
||||
|
|
@ -0,0 +1 @@
|
|||
shell ls: '*.slate'.
|
||||
|
|
@ -0,0 +1 @@
|
|||
OS.Process.system "ls"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
$$ MODE TUSCRIPT
|
||||
system=SYSTEM ()
|
||||
IF (system=="WIN") THEN
|
||||
EXECUTE "dir"
|
||||
ELSEIF (system.sw."LIN") THEN
|
||||
EXECUTE "ls -l"
|
||||
ENDIF
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
needs shell
|
||||
" ls" system
|
||||
|
|
@ -0,0 +1 @@
|
|||
ls
|
||||
|
|
@ -0,0 +1 @@
|
|||
exec ls
|
||||
|
|
@ -0,0 +1 @@
|
|||
output=`ls`
|
||||
|
|
@ -0,0 +1 @@
|
|||
output=$(ls)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
output=`expr \`echo hi | wc -c\` - 1`
|
||||
output=$(expr $(echo hi | wc -c) - 1)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
echo "Found: `grep 80/tcp /etc/services`"
|
||||
echo "Found: $(grep 80/tcp /etc/services)"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
ls # run command, return to shell
|
||||
exec ls # replace shell with command
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
set output=( "`grep 80/ /etc/services`" )
|
||||
echo "Line 1: $output[1]"
|
||||
echo "Line 2: $output[2]"
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#import std
|
||||
#import cli
|
||||
|
||||
#executable ('parameterized','')
|
||||
|
||||
myls = <.file$[contents: --<''>]>@hm+ (ask bash)/0+ -[ls --color=no]-!
|
||||
|
|
@ -0,0 +1 @@
|
|||
system("dir", DOS)
|
||||
|
|
@ -0,0 +1 @@
|
|||
system('cmd /k "dir"')
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
Attribute VB_Name = "mdlShellAndWait"
|
||||
Option Explicit
|
||||
|
||||
Private Declare Function OpenProcess Lib "kernel32" _
|
||||
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
|
||||
ByVal dwProcessId As Long) As Long
|
||||
|
||||
Private Declare Function GetExitCodeProcess Lib "kernel32" _
|
||||
(ByVal hProcess As Long, lpExitCode As Long) As Long
|
||||
|
||||
Private Const STATUS_PENDING = &H103&
|
||||
Private Const PROCESS_QUERY_INFORMATION = &H400
|
||||
|
||||
'
|
||||
' Little function go get exit code given processId
|
||||
'
|
||||
Function ProcessIsRunning( processId as Long ) as Boolean
|
||||
Dim exitCode as Long
|
||||
Call GetExitCodeProcess(lProcessId, exitCode)
|
||||
ProcessIsRunning = (exitCode = STATUS_PENDING)
|
||||
End Function
|
||||
|
||||
' Spawn subprocess and wait for it to complete.
|
||||
' I believe that the command in the command line must be an exe or a bat file.
|
||||
' Maybe, however, it can reference any file the system knows how to "Open"
|
||||
'
|
||||
' commandLine is an executable.
|
||||
' expectedDuration - is for poping up a dialog for whatever
|
||||
' infoText - text for progressDialog dialog
|
||||
|
||||
Public Function ShellAndWait( commandLine As String, _
|
||||
expectedDuration As Integer ) As Boolean
|
||||
|
||||
Dim inst As Long
|
||||
Dim startTime As Long
|
||||
Dim expirationTime As Long
|
||||
Dim pid As Long
|
||||
Dim expiresSameDay As Boolean
|
||||
|
||||
On Error GoTo HandleError
|
||||
|
||||
'Deal with timeout being reset at Midnight ($hitForBrains VB folks)
|
||||
startTime = CLng(Timer)
|
||||
expirationTime = startTime + expectedDuration
|
||||
expiresSameDay = expirationTime < 86400
|
||||
If Not expiresSameDay Then
|
||||
expirationTime = expirationTime - 86400
|
||||
End If
|
||||
|
||||
inst = Shell(commandLine, vbMinimizedNoFocus)
|
||||
|
||||
If inst <> 0 Then
|
||||
pid = OpenProcess(PROCESS_QUERY_INFORMATION, False, inst)
|
||||
|
||||
Do While ProcessIsRunning( pid)
|
||||
DoEvents
|
||||
If Timer > expirationTime And (expiresSameDay Or Timer < startTime) Then
|
||||
Exit Do
|
||||
End If
|
||||
Loop
|
||||
ShellAndWait = True
|
||||
Else
|
||||
MsgBox ("Couldn't execute command: " & commandLine)
|
||||
ShellAndWait = False
|
||||
End If
|
||||
|
||||
Exit Function
|
||||
|
||||
HandleError:
|
||||
MsgBox ("Couldn't execute command: " & commandLine)
|
||||
ShellAndWait = False
|
||||
End Function
|
||||
|
||||
Sub SpawnDir()
|
||||
ShellAndWait("dir", 10)
|
||||
End Sub
|
||||
|
|
@ -0,0 +1 @@
|
|||
PAUSE 100
|
||||
Loading…
Add table
Add a link
Reference in a new issue