genie-logo

System access

Page updated October 27, 2009
There is not yet an official logo for Genie/Vala, above image just a placeholder.
NOTICE
These Genie/Vala pages are no longer being updated, as I have defected. I have found BaCon to be more suited to my purposes: http://bkhome.org/bacon/

Introduction

Since early 2003 I have mostly been coding in Bash/Ash script, and I am very familiar with many of the low-level Linux/Unix utilties, especially those that are designed to work with piped stdin and stdout. As I often know how to get something done quickly using them, and I am less familiar with what is on offer amongst the Glib/libc functions (and how to use them), it is a matter of expedience if I can drop down to a shell process in a Genie program. That's mostly what this page is about.

The most relevant documentation:

http://references.valadoc.org/glib-2.0/GLib.Process.html
http://library.gnome.org/devel/glib/stable/glib-Spawning-Processes.html



This looks like an appropriate function, doesn't it? But complicated...
 public  bool spawn_sync (string? working_directory, string[] argv, string[]? envp, GLib.SpawnFlags _flags, GLib.SpawnChildSetupFunc? child_setup, [out string standard_output, out string standard_error, out int exit_status]) throws GLib.SpawnError 
This one is similar to the above, but simplified, with little-used parameters removed:
 public  bool spawn_command_line_sync (string command_line, [out string standard_output, out string standard_error, out int exit_status]) throws GLib.SpawnError 
So, let's use spawn_command_line_sync(). Here is a simple example that runs the echo utility application...
init
ret_stdout:string
ret_stderr:string
ret_status:int
Process.spawn_command_line_sync("echo 'hey it works!'",out ret_stdout,out ret_stderr,out ret_status)
print(ret_stdout)
Most of the above should be easily understandable, but if you are unfamiliar with Genie the out may be a mystery -- it specifies that the variable is to be passed by reference (the default is by value) -- see my page on Genie functions.







(c) Copyright 2008,2009 Barry Kauler puppylinux.com, all reproduction rights reserved.