ich schreibe gerade ein kleines Script um den Musiktitel usw von Amarok über ein µC an einem LCD auszugeben.
Die Ausgabe des Musiktitel erreiche ich auf der Konsole mit:
dcop amarok player title
Der Title wird dann auf stdout ausgegeben.
Jetzt habe ich in meinem C Programm eine kleine Funktion um Befehle aufzurufen.
Code: Alles auswählen
int RunCommand(const char *strCommand)
{
int iForkId, iStatus;
iForkId = vfork();
if (iForkId == 0) // This is the child
{
iStatus = execl("/bin/sh","sh","-c", strCommand, (char*) NULL);
exit(iStatus); // We must exit here,
// or we will have multiple
// mainlines running...
}
else if (iForkId > 0) // Parent, no error
{
iStatus = 0;
}
else // Parent, with error (iForkId == -1)
{
iStatus = -1;
}
return(iStatus);
}
Code: Alles auswählen
int iStatus = RunCommand("dcop amarok player title");
Ich habe schon daran gedacht mit > im Befehl die Ausgabe in eine Datei zu schreiben und diese dann wieder einzulesen, aber ich denke das wäre recht unschön.
Hat jemand eine Idee?
Gruß Tobi