Boltgreywing Posted September 10, 2017 Share Posted September 10, 2017 I am having difficulty setting variables in linux. I have a program called calz but it seeing it as ./calz instead of calz to run. Its C++ and I was wondering how do I tell it to do calz instead of ./calz. I have tried changing my linux profile but it wound up screwing it more and I could use a lot of help to get this working correctly. I need this to make my donationbox ruby code actually work. Quote Link to comment Share on other sites More sharing options...
owlmanatt Posted September 10, 2017 Share Posted September 10, 2017 The `calz` binary should be in your shell's $PATH. $PATH is a list of folders it'll check for executables, which is what allows you to just type calz. You have two options: you can move it to a folder in $PATH (run `echo $PATH` to get the list), or you can add another dir to $PATH. nevans@chi:~$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/nevans/.composer/vendor/bin/ nevans@chi:~$ cd test_913/ nevans@chi:~/test_913$ ls dummy_executable # This is the problem nevans@chi:~/test_913$ dummy_executable -bash: dummy_executable: command not found nevans@chi:~/test_913$ ./dummy_executable Hello world! I have run successfully! # Solution 1 - move it somewhere in the $PATH nevans@chi:~/test_913$ sudo cp dummy_executable /usr/local/bin [sudo] password for nevans: nevans@chi:~/test_913$ dummy_executable Hello world! I have run successfully! nevans@chi:~/test_913$ which dummy_executable /usr/local/bin/dummy_executable # Solution 2 - add a new folder to the $PATH. nevans@chi:~/test_913$ echo 'PATH="$PATH:/home/nevans/test_913"' >> ~/.bashrc nevans@chi:~/test_913$ source ~/.bashrc nevans@chi:~/test_913$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/nevans/.composer/vendor/bin/:/home/nevans/test_913 nevans@chi:~/test_913$ dummy_executable Hello world! I have run successfully! nevans@chi:~/test_913$ which dummy_executable /home/nevans/test_913/dummy_executable Note that solution #2 is only adding that dir for your current user. If the webserver needs to add an entry to its $PATH, that'd be a mite bit different. 2 Quote Link to comment Share on other sites More sharing options...
Boltgreywing Posted September 11, 2017 Author Share Posted September 11, 2017 4 hours ago, owlmanatt said: The `calz` binary should be in your shell's $PATH. $PATH is a list of folders it'll check for executables, which is what allows you to just type calz. You have two options: you can move it to a folder in $PATH (run `echo $PATH` to get the list), or you can add another dir to $PATH. nevans@chi:~$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/nevans/.composer/vendor/bin/ nevans@chi:~$ cd test_913/ nevans@chi:~/test_913$ ls dummy_executable # This is the problem nevans@chi:~/test_913$ dummy_executable -bash: dummy_executable: command not found nevans@chi:~/test_913$ ./dummy_executable Hello world! I have run successfully! # Solution 1 - move it somewhere in the $PATH nevans@chi:~/test_913$ sudo cp dummy_executable /usr/local/bin [sudo] password for nevans: nevans@chi:~/test_913$ dummy_executable Hello world! I have run successfully! nevans@chi:~/test_913$ which dummy_executable /usr/local/bin/dummy_executable # Solution 2 - add a new folder to the $PATH. nevans@chi:~/test_913$ echo 'PATH="$PATH:/home/nevans/test_913"' >> ~/.bashrc nevans@chi:~/test_913$ source ~/.bashrc nevans@chi:~/test_913$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/nevans/.composer/vendor/bin/:/home/nevans/test_913 nevans@chi:~/test_913$ dummy_executable Hello world! I have run successfully! nevans@chi:~/test_913$ which dummy_executable /home/nevans/test_913/dummy_executable Note that solution #2 is only adding that dir for your current user. If the webserver needs to add an entry to its $PATH, that'd be a mite bit different. @owlmanatt: I tried this solution you gave me but it kind of failed. eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ calzNo command 'calz' found, did you mean: Command 'cal' from package 'bsdmainutils' (main) Command 'calc' from package 'apcalc' (universe) calz: command not found eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ echo $PATH~/Resources/Code/donationbox/:/home/eric/bin:/home/eric/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ sudo cp calz ~/Resources/Code/donationbox [sudo] password for eric: cp: cannot create regular file '/home/eric/Resources/Code/donationbox': No such file or directory eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ source ~/.profile eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ ls boxrate.cpp boxrate.o calz Makefile tax.cpp tax.o eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ echo $PATH/home/eric/bin:/home/eric/.local/bin:~/Resources/Code/donationbox/:/home/eric/bin:/home/eric/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ echo 'PATH="$PATH:/home/eric/Resources/Code/dbox"' >> ~/.bashrc eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ source ~/.bashrc eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ echo $PATH/home/eric/bin:/home/eric/.local/bin:~/Resources/Code/donationbox/:/home/eric/bin:/home/eric/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/eric/Resources/Code/dbox eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ ls boxrate.cpp boxrate.o calz Makefile tax.cpp tax.o eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ calz No command 'calz' found, did you mean: Command 'cal' from package 'bsdmainutils' (main) Command 'calc' from package 'apcalc' (universe) calz: command not found eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ ./calz eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ Quote Link to comment Share on other sites More sharing options...
owlmanatt Posted September 11, 2017 Share Posted September 11, 2017 Is calz executable? chmod +x calz 1 Quote Link to comment Share on other sites More sharing options...
Boltgreywing Posted September 13, 2017 Author Share Posted September 13, 2017 On 9/11/2017 at 5:36 AM, owlmanatt said: Is calz executable? chmod +x calz @owlmanatt: It is as can be seen by ls -la eric@eric-PORTEGE-R830:~/Projects/Local/Websites/Resources/Code/dbox$ ls -la total 44 drwxrwxr-x 2 eric eric 4096 Sep 10 14:44 . drwxrwxr-x 3 eric eric 4096 Sep 10 14:44 .. -rw-rw-r-- 1 eric eric 579 Sep 9 23:38 boxrate.cpp -rw-rw-r-- 1 eric eric 2976 Sep 10 14:44 boxrate.o -rwxrwxr-x 1 eric eric 13528 Sep 10 14:44 calz -rw-rw-r-- 1 eric eric 130 Sep 10 14:44 Makefile -rw-rw-r-- 1 eric eric 952 Sep 8 22:59 tax.cpp -rw-rw-r-- 1 eric eric 2448 Sep 10 14:44 tax.o Quote Link to comment Share on other sites More sharing options...
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.