C/C++ Helper.\\n");
break;
default:
printf("Invalid choice!\\n");
break;
}
if (choice != 0) {
printf("\\n[Press Enter to continue...\]");
while (getchar() != '\\n');
getchar();
}
} while (choice != 0);
}
void rm(void)
{
char rm_file[80\];
printf("file want to remove ? ");
fgets(rm_file, sizeof(rm_file), stdin);
rm_file[strcspn(rm_file, "\\n")\] = '\\0';
char sure[10\];
printf("Sure ? Y/n : ");
fgets(sure, sizeof(sure), stdin);
sure[strcspn(sure, "\\n")\] = '\\0';
if (strcmp(sure, "y") == 0 || strcmp(sure, "Y") == 0) {
pid_t pid = fork();
if (pid == 0) {
char *args[\] = {"sudo", "rm", rm_file, NULL};
execvp(args[0\], args);
perror("failed execvp");
exit(1);
}
else {
wait(NULL);
}
} else {
return;
}
}
void systeminfo(void)
{
pid_t pid = fork();
if (pid == 0) {
char *args[\] = {"sh", "-c", "ls && lsblk && ls /", NULL};
execvp(args[0\], args);
perror("failed execvp");
exit(0);
}
else {
wait(NULL);
}
}
void rep(void)
{
while(1) {
char rep_cmd[50\];
printf(" what do you want?\\n"
"<how to see info of system linux>\\n"
"<how to get remove file in this system>\\n"
"<how to get install pkg>\\n"
"c_cpp_helper\\n"
"<how to install wsl in this system \\\\ powershell>: ");
fgets(rep_cmd, sizeof(rep_cmd), stdin);
rep_cmd[strcspn(rep_cmd, "\\n")\] = '\\0';
if (strcmp(rep_cmd, "how to see info of system linux") == 0) {
printf("in your terminal , getting command ls, lsblk, ls /, whoami, in this system, you command the systeminfo\\n");
} else if (strcmp(rep_cmd, "how to get remove file in this system") == 0) {
printf(" in your terminal, getting command rm and your file path wanted to remove, in this system you command rm and write the path file\\n");
} else if (strcmp(rep_cmd, "how to get install pkg") == 0) {
printf("sudo and your pkg and your pkg , in this system, just command inst and select pkgmanager, select pkg\\n");
} else if (strcmp(rep_cmd, "how to install wsl in this system \\\\ powershell") == 0) {
printf(" you really use window bruhhh haha, just command wsl --install Ubuntu or in this system, just command wslinstubuntu\\n");
} else if (strcmp(rep_cmd, "c_cpp_helper") == 0) {
printf("command the c_cpp_helper for the c and c++ helper");
} else {
exit(0);
}
}
}
int main(void) {
char user_input[256\];
while(1) {
input_cmd(user_input, sizeof(user_input));
if (strcmp(user_input, "wslinstubuntu") == 0) {
wslinstubuntu();
} else if (strcmp(user_input, "inst") == 0) {
inst();
} else if (strcmp(user_input, "rm") == 0) {
rm();
} else if (strcmp(user_input, "systeminfo") == 0) {
systeminfo();
} else if (strcmp(user_input, "c_cpp_helper") == 0) {
c_cpp_helper();
} else if (strcmp(user_input, "rep") == 0) {
rep();
} else if (strcmp(user_input, "exit") == 0) {
break;
} else {
printf("not found ***\\n");
}
}
return 0;
}
this is the TuxExec v0.02 source , just the simple c_cpp_helper update
\#include <stdio.h>
\#include <unistd.h>
\#include <sys/types.h>
\#include <sys/wait.h>
\#include <stdlib.h>
\#include <string.h>
void input_cmd(char *buf, size_t size)
{
printf("TuxExec: ");
if (fgets(buf, size, stdin) != NULL) {
buf[strcspn(buf, "\\n")\] = '\\0';
}
}
void wslinstubuntu(void)
{
system("wsl --install -d Ubuntu");
printf("window fuckass using wsl btw =)) ");
}
void inst(void)
{
char pkgmn[256\];
printf("Linux pkgmn = ? (pacman ,apt , dnf): ");
fgets(pkgmn, sizeof(pkgmn), stdin);
pkgmn[strcspn(pkgmn, "\\n")\] = '\\0';
if (strcmp(pkgmn, "apt") == 0) {
while(1) {
char apt[512\];
printf("pkg install: ");
fgets(apt, sizeof(apt), stdin);
apt[strcspn(apt, "\\n")\] = '\\0';
pid_t pid = fork();
if (pid < 0) {
perror("pid failed");
}
else if (pid == 0) {
char *args[\] = {"sudo", "apt", "install", apt, NULL};
execvp(args[0\], args);
perror("failed execvp");
exit(1);
}
else
Post #43120
21