alexander Posted March 21, 2007 Report Posted March 21, 2007 if you want to run the program in the debugger (in my opinion the greatest debugger in the world) you can compile it using -ggdb or #g++ -o prog prog.cpp -ggdbthen you can run it in gdb by #gdb prog, from there there are numbers of possibilities, gdb will save your life in tough situations, its a good tool to learn how to use, it's saved me tonns of times... Quote
Buffy Posted March 21, 2007 Report Posted March 21, 2007 lol guys its ./hello not just hello :lol:We hackers know that, but you want to make sanctus or my grandma have to remember to type "./" in front of every command? I can see it now, the next Microsoft propaganda ad: "The Linux folks want you to have to remember to always type './' before every command!" Blame alexander,Buffy Quote
alexander Posted March 21, 2007 Report Posted March 21, 2007 its not a command, its a program! and ./ signifies that you are about to run an executable. It is not safe adding your user directory to the list of global vars, simply for security sake! Therefore it is much simpler to remember that ./ runs an executable then making your box a dream for a hacker, ok :)besides ./ are next to each other on the keyboard so they are quick to type, and also its not like you have to remember to type in eneffulgenosesquipedaliperenialiffication or something, it's ./ There is a harder way of doing this and that is writing a config script and then doing make and make install, which will add the executable to /usr/bin or /usr/sbin, or you could do it manualy and then reload the shell, but that is too much work, just do ./ seriously it is not that difficult, its fewer clics then it would take you to run the same program in windows, trust me :) Quote
alexander Posted March 21, 2007 Report Posted March 21, 2007 oh you could also add a man page to man so you know what hello command does :) Quote
Buffy Posted March 21, 2007 Report Posted March 21, 2007 ... ./ signifies that you are about to run an executable.Works for shell scripts too dear!It is not safe adding your user directory to the list of global vars, simply for security sake! Therefore it is much simpler to remember that ./ runs an executable then making your box a dream for a hacker, ok :)Oh do tell! How does it make your system less secure? (I don't doubt that it does, just wanna know how!) Back in the old days, what we all usually did for small (or personal) stuff is create a directory:~buffy/binadd it to command path and then have a simple makefile (usually just copied from the last program):myprog: myprog.c myproglib.c cc -o myprog myprog.c myproglib.c cp myprog ~/bin which would not only allow you to immediately test it by typing "myprog" but test it anywhere, or just use it as a new program for your own personal use. Used to be common to do this to have your own custom versions of common programs and utilities. I guess I'd have the follow on question of, if your path is as long as sanctus' is above, you've got a major security hole right there! Are you saying that programs--all programs no matter whose they are--should all be installed in the top level of /usr/bin for security reasons? That sounds awfully inflexible... I can definitely see that not having . in the global .xxxrc file is a good thing: its arguably dangerous and unnecessary for restricted users, but for people who are compiling programs, I'd personally think it would be fine to put it in ~/.xxxxrc...tell me otherwise though...its fewer clics then it would take you to run the same program in windows, trust me :)When it comes to Windoze versus Linux, we always do alex! :) All operating systems are created evil, :)Buffy Quote
sanctus Posted March 22, 2007 Author Report Posted March 22, 2007 Well in alex's way it works thanks, just I do not call the "." (which is on the line just above the space bar a bit on the right) and the "/" right next to each other as in western european keyboards the /-key = SHIFT+7 :) Now Buffy I still tried to change as you said, my .bashrc file looks now like (you can delete it alex if it is dangerous): # .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific aliases and functions export CMBEASYDIR=(...) #to make comands run set PATH $PATH:. echo $PATH the things after the if fi statement is to make run cmbeasy, that's why I had such a long path before. And for the ls -l hello* I get: -rwxrwxrwx 1 sandro sandro 6115 Mar 19 14:26 hello but I still can't write just hello. But don't worry in case it would take too much time to figure it out, I tried long enough and I'm still mentally fit enough to not forget easily the ./ ... Quote
Buffy Posted March 22, 2007 Report Posted March 22, 2007 I'm no bash expert, but it looks like you need to use the export command to get it to work (technically speaking (as the Mythbusters would say, "Warning: Science Content!") bash is more sh-like than csh-like and you've got a scoping problem here that's solved in sh and bash with "export" and "setenv" in csh, but you can forget this entire, eye-glazing parenthetical remark), so delete the lines you added per me, and add the bolded line below and it should work. ... export GSLCMBDIR=$CMBEASYDIR/gsl export PATH=$PATH:$CMBEASYDIR/bin [b]export PATH=$PATH:.[/b] ... the file listing looks like you have it set right permission-wise and the fact that "./hello" works indicates its okay on that front. Once you get the .bashrc edited--and remember to start a new shell: the .bashrc only runs when the shell is opened--it should work fine. If you then type:echo $PATHon the command line, you should see the entire path with all the CMBEASY references along with "/bin" and other good locations, followed by the "." Sorry, I went to Berkeley and csh is the cat's pajamas,Buffy Quote
sanctus Posted March 22, 2007 Author Report Posted March 22, 2007 Yes , now it works, but only if I'm in the right directory and ergo it doesn't search all hello programs stored on my OS which is good. Thanks very much. Quote
Buffy Posted March 22, 2007 Report Posted March 22, 2007 Yes , now it works, but only if I'm in the right directory and ergo it doesn't search all hello programs stored on my OS which is good. Thanks very much.That's precisely what its supposed to do. Unsaid--amazingly--in this entire thread is the fact that "." is *nix for "the current directory" and the source of ".." which means "the parent of the current directory" for those of you who have been bewildered by what this all meant.... mv buffys_blatherings /dev/null,Buffy Quote
alexander Posted March 23, 2007 Report Posted March 23, 2007 instead of restarting the terminal, you can also do #source .bashrcif you want to run a program and its in a subdirectory, you can do ./direcotry/another_one/program and that will work too sanctus ;) and i would delete that cmbeasydir variable from your .bashrc, that to me is just asking for trouble if someone (*caugh hacker*) sees it ;) Quote
sanctus Posted March 24, 2007 Author Report Posted March 24, 2007 Yes but it is the only way of making the programcmbeasy run Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.