![]() |
| | #1 |
| Registered User Join Date: Dec 2006
Posts: 15
| Problem with system(), execl(), etc. functions Im trying to create an alias on a Linux system, which is very simple done through the command line by "alias my_command=another_command" for example, and then to remove the alias you use "unalias my_command". The problem is when I use system(), or the whole range of exec functions none of them work (for both creating, and removing the alias). Any ideas? |
| nickkrym is offline | |
| | #2 |
| Deathray Engineer Join Date: Mar 2007
Posts: 3,211
| I wrote some code before. It didn't work either. Why? Get the idea? You're not giving enough information. I think I'm going to suggest that the phrase "doesn't work" get auto-replaced on these forums by something else, at least when used at the end of a sentence.
__________________ |
| MacGyver is offline | |
| | #4 |
| Registered User Join Date: Dec 2006
Posts: 15
| Sorry for the lack of details. What it boils down to is that the system already has an alias defined and I need to remove it. The relevant part of my application (called "plz"): Code: system("unalias temp");
root@nick:/home/nick# alias alias ls='ls --color=auto' root@nick:/home/nick# alias temp=/some/link root@nick:/home/nick# alias alias ls='ls --color=auto' alias temp='/some/link' root@nick:/home/nick# ./plz sh: line 0: unalias: temp: not found root@nick:/home/nick# alias alias ls='ls --color=auto' alias temp='/some/link' |
| nickkrym is offline | |
| | #5 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,699
| system() and exec() functions are for running actual programs. Aliases in your shell are basically nothing more than inline macros which get expanded into doing something by the shell. I hope you don't surf the web as well as doing development work as root. |
| Salem is offline | |
| | #6 |
| Registered User Join Date: Dec 2006
Posts: 15
| Thanks for the reply. So is it possible to envoke these macros from within a C application? Something along the lines of 'echo "unalias temp" | /bin/bash'? I usually don't use root but I was doing some configuration a second before i posted that, but thanks for noticing |
| nickkrym is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Directory and System Problem | swanley007 | C++ Programming | 6 | 07-27-2006 12:32 PM |
| problem w/ color functions && win98 :P | DarkMortar | C Programming | 2 | 06-07-2006 04:45 PM |
| GTK+ Gnome desktop system tray app problem | BobS0327 | Linux Programming | 2 | 04-01-2006 09:54 PM |
| problem with multimaps and virtual functions | schlamniel | C++ Programming | 4 | 08-11-2004 08:39 AM |
| Functions problem. *Need Help* | Unregistered | C Programming | 4 | 03-28-2002 12:50 PM |