Created
October 16, 2017 01:02
-
-
Save jnikolak/bf9306d700c490e43cb6e476f62d683b to your computer and use it in GitHub Desktop.
Shell Prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
void prompt(); | |
int main() | |
{ | |
char hostname[1024]; | |
gethostname(hostname, 1024); | |
int loop = 0; | |
char input[32]; | |
while(1) | |
{ | |
prompt(); | |
fgets(input,31,stdin); | |
loop++; | |
} | |
return(0); | |
} | |
/* Display prompt */ | |
void prompt() | |
{ | |
char hostname[1024]; | |
gethostname(hostname, 10); | |
printf("[root@%s]# ",hostname); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment