Execute a system command: Difference between revisions

no edit summary
No edit summary
Line 578:
 
execute( if $os.startsWith('Windows') then 'dir' else 'ls' )</lang>
 
=={{header|FutureBasic}}==
This simple example prints the output to a console window. FB has robust capability as a system interface to the Free BSD Unix core of Macintosh OS X 10.x.
<lang futurebasic>
include "ConsoleWindow"
 
local fn DoUnixCommand( cmd as str255 )
dim as str255 s
 
open "Unix", 2, cmd
while ( not eof(2) )
line input #2, s
print s
wend
close 2
end fn
 
fn DoUnixCommand( "ls -A" )
</lang>
 
Output:
<pre>
.DocumentRevisions-V100
.Spotlight-V100
.Trashes
.file
.fseventsd
.hotfiles.btree
.vol
Applications
Library
Network
System
Users
Volumes
bin
cores
dev
etc
home
mach_kernel
net
private
sbin
tmp
usr
var
</pre>
 
=={{header|Go}}==
715

edits