I'm working on tool to allow you to easily change your Trackpoint settings on the Lenovo thinkpads. The little nipple. I'm writing it in C to help me learn the language more. I'm having a problem I can't quite put my paw on.

The code responsible for changing the setting is:

int set_nipple_speed(int speed) { if (speed <= 0) { printf("Invalid value %d speed must be greater than 0", speed); return 1; } char command[100]; char * path = get_trackpoint_path(); sprintf(command, "echo %d | sudo tee %s/serio2/speed", speed, path); return system(command); }
I'm getting:
tee: /sys/devices/platform/i8042/serio1: Is a directory 33 sh: 2: /serio2/speed: not found
Oh and theres a function being called to get the base path to get to the trackpoint settings:
char *get_trackpoint_path() { FILE *pipe_stream = popen("find /sys/devices/platform/i8042 -name name | xargs grep -Fl " "TrackPoint | sed 's/\\/input\\/input[0-9]*\\/name$//'", "r"); char path[2048]; if (pipe_stream == NULL) { printf("Failed to run command to find trackpoint path"); return NULL; } fgets(path, sizeof(path), pipe_stream); pclose(pipe_stream); char *path_ptr = path; return path_ptr; }
Would anyone be willing to help me
#debug this? I'm pretty new to C. Project is here #codinghelp

I seems like the string in command is being cut off. The /serio2/speed is getting cut off for some reason. #codinghelp