| |
comp.os.linux.misc |
/*
******** home command ********
The 'home'command takes you to your home directory if
you've been wandering far, and don't want to type so
much. Just type "home" at the shell, and you're immediatly
transported to /home/yourusername/
(c) 2004 Mike Cox. Released under the GNU GPL License.
email: mikecoxli...@yahoo.com
web: www.geocities.com/mikecoxlinux/
compile instructions:
g++ -o home home.cpp
install instructions:
move it to the /bin directory.
..Or create a Makefile as follows:
home: home.cpp
g++ -o home home.cpp
install:
mv home /bin/
clean:
rm home
*/
#include <iostream>
int main()
{
char* name= new char[strlen(getlogin()) + 1];
strcpy(name,getlogin());
if(strcmp(name, "root") == 0)
{
std::cout<<"going to home directory...\n";
FILE* pipe;
pipe = popen("cd /root/", "w");
pclose(pipe);
} else{
char* base = "/home/";
strcat(base, name);
FILE* bong;
std::cout<<"going to home directory...\n";
bong = popen(base,"w");
pclose(bong);
}
delete [] name;
return 0;