Need some help with this...


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 22  
choose one that works and do popen("ksh -c alias","r") or which ever you choose, noting of course the format of the data it produces.
# 23  
Quote:
Originally Posted by Legend986
The alias command works if I type it outside the program
Which shell do you normally use? Try "ps -p $$".
# 24  
Its bash... Ok I need to construct that string in this manner:

"csh -c "alias ls""

Hehe... if it was php I would've gotten away by typing "csh -c \"alias ls\""...

And Bingo... it works even here Smilie

Last edited by Legend986; 09-30-2007 at 11:00 PM..
# 25  
I was trying to refine my program. So I was just changing the order. I mean when something like ./uwhich -r ls is passed, it has to display the alias as well as the path to ls. It was displaying in the reverse order i.e. first path and then alias so i just interchanged the if logic by putting if(readalias == 1) first and if(allpaths == 1) as second one. But now, the second if loop is not displaying anything. I mean it is entering the loop but nothing is happening. Could I be doing something wrong here?

And as a matter of fact, if I want to find the particular command not just using the $PATH environment variable but in the whole system, is there any other variable for that? I mean, I should be able to get the variable wherever it is.

Last edited by Legend986; 10-01-2007 at 01:11 PM..
# 26  
Quote:
Originally Posted by Legend986
And as a matter of fact, if I want to find the particular command not just using the $PATH environment variable but in the whole system, is there any other variable for that?
No, but you could recurse yourself using opendir/readdir/closedir or by popen("find / -print","r")
# 27  
I thought so. Hehe... I thought there could be another environment variable for this purpose. Blame it on my ignorance... And any idea about the first question too?
# 28  
Quote:
Originally Posted by Legend986
I thought so. Hehe... I thought there could be another environment variable for this purpose.
No, otherwise the variable would have to change everytime somebody created or removed a directory.

Quote:
Originally Posted by Legend986
And any idea about the first question too?
Not really as we can't see your code from here, sounds like an uninitialised variable or mistaken assumption.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #294
Difficulty: Easy
Ubuntu is a free and open-source Linux distribution based on Slackware.
True or False?

Featured Tech Videos