[Vala] spawn_command_line_asyn with dinamic variable



hi,
i just want to run command like bashscript. so i can put dinamyc variable.
this my sample bash script

#!/bin/bash
STR=brasero
apt-get install $STR -y

and this my vala code

public static JSCore.Value installapp (Context ctx,
JSCore.Object function,
JSCore.Object thisObject,
JSCore.Value[] arguments,
out JSCore.Value exception) {
 exception = null;

var nama = "brasero";

//run program with root previlage or run gksudo, its show a box root
try {
Process.spawn_command_line_async ("sudo apt-get install $nama -y");
} catch (SpawnError e) {
stdout.printf ("Error: %s\n", e.message);
}
return new JSCore.Value.undefined (ctx);
}

but when i run the program, i got this message :
*Reading package lists... Done*
*Building dependency tree       *
*Reading state information... Done*
*E: Unable to locate package $nama*
*E: Couldn't find any package by regex '$nama'*

did I missing something?

this my github :
https://github.com/tuanpembual/Testing/blob/master/app.vala#L62

thanks a lot of.

- Estu Fardani -
+62 856 432 14898
Linux Blog: http://tuanpembual.wordpess.com<http://tuanpembual.wordpress.com>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]