簡體   English   中英

如何使用c中的路徑更改xeyes的顏色?

[英]how to change color of xeyes using a path in c?

這一切在Linux中不是Windows

你好,我想知道我如何像在終端一樣改變xeyes的顏色

xeyes -fg blue現在我想使用路徑在C程序中執行此操作

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

#include <string.h>
#include <malloc.h>

//#inlcude <windows.h>

#define LB_SIZE 1024

int main(int argc, char *argv[])
{
  char fullPathName[] = "/usr/bin/X11/xeyes";
  char *myArgv[LB_SIZE];  // an array of pointers

  myArgv[0] = (char *) malloc(strlen(fullPathName) + 1);
  strcpy(myArgv[0], fullPathName);

  myArgv[1] = NULL;  // last element should be a NULL pointer

  execvp(fullPathName, myArgv);
  exit(0);  // should not be reached
}

如果我只是簡單地調用/ usr / bin / X11 / xeyes,它只會顯示眼睛

現在我正在嘗試添加/ usr / bin / X11 / xeyes-fg之類的命令,但是它不起作用

有什么建議嗎?

您可以添加到參數向量,如下所示:

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

#include <string.h>
#include <malloc.h>

#define LB_SIZE 1024

int main(int argc, char *argv[])
{
  char fullPathName[] = "/usr/bin/X11/xeyes";
  char *myArgv[LB_SIZE];  // an array of pointers
  int n = 0;

  myArgv[0] = (char *) malloc(strlen(fullPathName) + 1);
  strcpy(myArgv[n++], fullPathName);
  myArgv[n++] = "-fg";
  myArgv[n++] = "blue";

  myArgv[n] = NULL;  // last element should be a NULL pointer

  execvp(fullPathName, myArgv);
  exit(0);  // should not be reached
}

這是結果的圖片: xeyes-藍點

副手,我希望strace顯示正在打開的文件rgb.txt,但不會使用-f選項看到此情況(假定它發生在服務器中)。 “藍色”確實顯示在跟蹤中,但僅顯示在exec調用中,例如,

execve("/usr/bin/X11/xeyes", ["/usr/bin/X11/xeyes", "-fg", "blue"], [/* 62 vars */]) = 0

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM