iccaros

Linux Experts
  • Content Count

    1292
  • Joined

  • Last visited

Everything posted by iccaros

  1. ok here is my shell starter for the adventure game.. it does nothing but print a banner and do a quick two dice roll.. need to add +++ everything.. plus I need to comment so I can keep on track.. I'm learning how to read and write files.. I think it would be better if all detail were in a text file.. this way .. this is just an engian and can be more basic.. read part of file in to array. save game to file things like that. a config file would tell the engian how many rooms and frequencey of monsters / items bash-2.05b$ cat adventure.cpp /*************************************************
  2. yes.. LFS was my first Lunx system I did not buy... I bought Red hat since 5.0 (downloaded a very early version in 1994 but it would not run on my compaq with SCSI drives) LFS and BLFS are both great book I keep, a trick I did was to make a PDF and print them so for me they are books. as for side tracking... this is what I wanted this post to be.. people posting hwo to get answers or tricks that are not standard Linux users stuff.. so comment away.
  3. I thought I pass on a tip so some people learning how to administer unix/linux systems.. if you have a few workers on the same box or multiple boxes (like a work enviroment..) how do you make sure all have the same settings (ie .profile .bash .csh and starting and ending scripts ) with out you coping them all to the indavidual computers? the answer is a dir called /etc/skel just place them there.. or better yet... make that a network mount so you just change that one location.. for more information see http://www.fr.linuxfromscratch.org/view/bl...stlfs/skel.html
  4. ya that is how I write also..
  5. JCL writes much better code.. so I have only one thing to add.. you should check to see if nfs mouted again after mounting .. that way no need to do it before runnnig the command.. they way you did it great .. even more so if you want to reuse code. (ie insted of a function make it a scritp and call the script) then anytime you need a script to check and mout the nts share they just call the script to do it.. I'll write up an example when I get a little time today.. good work.
  6. ok I did some changes adn it works 80% I had issues. but I deleated the post as it was a bad post anyways.. here is what I have now.. now I just need ot clean up input output to make it usefull thanks for the help.. bash-2.05b$ cat cal.cpp //text baased calcultor program #include <iostream> #include <cmath> #include <cstdlib> using namespace std; //standard protability between windows and unix calls.. //use the -DUNIX or -DWIN32 option for gcc void clear_screen() { #if defined WIN32 system("cls"); #elif defined UNIX system("clear"); #endif } //input prom
  7. the first line would show a mount point if not ran in a scripts... (it may need a >> /dev/null to make it not show) but if the grep is successful (meaning it found 192.168.1) it will return a status of zero (normal good exit status) the $? is the bash variable for exit status.. so we are checking if the mount | gerp 192.168.1 was a successful (found what it was lookng for ) or failed (with returns a 1) try it type mount | grep 192.168.1 >> /dev/null echo $? if your mount point is mounted you should see a zero if not mounted a 1 the != i s a logical not. so in english if ["return
  8. I know that picture from somewhere??
  9. LOL... or my dog did.... I know the case statments are not done.. but even if I change type = cin.get() to cin >> type; the program ends with 0 as a answer bash-2.05b$ cat cal.cpp //text baased calcultor program #include <iostream> #include <cmath> #include <cstdlib> using namespace std; //standard protability between windows and unix calls.. //use the -DUNIX or -DWIN32 option for gcc void clear_screen() { #if defined WIN32 system("cls"); #elif defined UNIX system("clear"); #endif } //input prompt and type checking double Number_Prompt ( const strin
  10. Programming can be a good thing to learn.. one thing I always like about you on the board shanenin is you never seam to fear doing something new.. as for my script.. its missing the done at the end to end the while.. glad it's making sence.. this is where I learned bash from http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
  11. ok first I would like to thank jcl for all the help.. FI you have a site I can send a donation to help pay for this training.. I am tring to make a calculator ... now I know a simple way to do it.. but I'm thick headed and I want to do a lot of diffrent things likecheck for correct input and stuff. I must be tired but this is my start.. the compiler does not like my cin.get() with a char.. ?? here we go.. to all the brave souls hint the end goal is to create a text based calculator that will act just like a gui one.. you type a number type function keep going till you hit enter and it gives
  12. this should do it.. the first was a mix of bash a c++ sorry i was tired... just change folder names as needed #!/bin/bash nfs_mount() { #replace followng line with you rmount command echo "nfs mount being mounted" } mount | grep 192.168.1 if [ "$?" != 0 ]; then nfs_mount fi # this will see what files are diffrent between the two directorys.. #first being the master second the oenfiles will be copyed to diff -q /folder1/name/ /folder2/name/ | cut -d ' ' -f4 > /tmp/copy_list # need to read file /tmp/copy_list and move those files. for i in $( cat /tmp/copy_list ); do cp /mast
  13. if (exit == 0) { break; //this is the break; where the compiler is giving me errors } else { system("PAUSE");} return 0;
  14. not done but first part.. need the file copy part.. will get to that tomarrow.. but I am posting incase people have a better way or can add on before I do.. #!/bin/bash nfs_mount() { #replace followng line with you rmoutn command echo "nfs mount being mounted" } nfs_chk ("mount | grep 192.168.1") if [ $? ne 0 ] than nfs_mount() fi # this will see what files are diffrent between the two directorys.. #first being the master second the oenfiles will be copyed to diff -q /folder1/name/ /folder2/name/ | cut -d ' ' -f4 > /tmp/copy_list # need to read file /tmp/copy_list and move those
  15. it works as long as you case it correctly.. the nice part is you can chnage this so questions and value coem from a file.... #include <iostream> using namespace std; int main () { char Test; int a = 12; int b = 7; cout << "Answer is 12 > or < 7 (enter > or <): "; cin >> Test; switch ( Test ) { case '>': if ( a > b ){ cout << "correct answer" << endl;} else cout << "wrong answer
  16. ok here is my final code with error checking.. Could I have made it smaller? #include <iostream> #include <cstdlib> using namespace std; // this is for portability of system call you must us the -DUNIX or -DWIN32 option for gcc // compiler replaces clear_screen() with system("cls"); if -DWIN32 is used with gcc // compiler replaces clear_screen() with system("clear") if -DUNIX is used with gcc void clear_screen() { #if defined WIN32 system("cls"); #elif defined UNIX system("clear"); #endif } //this is the prompt for gallons input with type
  17. ok I think I understand.. this is a function creaded before main() int prompt( const string& s) { while (true) { int val; cout << s << flush; cin >> val; if (cin.fail()) { cerr << "invalid input"; cin.clear(); cin.ignore(); } else { return val; } } } then in main() I have int val; while ((val = prompt("enter value: ")) != -1) { // etc } but for my understanding... the while (val ) test aginst the value of the return of prompt() and the prompt("enter val: ") tell the fi
  18. Thanks I need to play with it.. I think I understand but I probaly do not.. i see why people hate ths stuff. BASIC take me away..
  19. on other thing.. I would need to declare variables outside of main if I made prompt functions correct?
  20. xorry, by primitive I ment my soultion to use the saem error check to all input when not all input is the same
  21. thanks ..I had read that but I could not see the answer in their.. untill now.. sometimes I'm slow
  22. I get everything you did (thanks to comments.) but I do not get the two return 0; if ?I have a return 0 at the end do I need it in a else.. or can I dope the else all together?? is that even aprt of the error checking as my if ( != -1) looks like this (noticed the check OS function I barrowed from you) #include <iostream> #include <cstdlib> //needed for system calls using namespace std;// this is used instead of calling all the using std::cout or defining each std out void clear_screen() // this is for portability of system call you must us the -DUNIX or -DWIN32 option for gc
  23. ok I have a problem, I have a program that runs but only if you put the correct type of input.. ie I have a int feet if on cin >> feet the user puts: a it put a loop that confuses the program requiring cntrl-c to stop is there a way to test this varable to see if the input type is correct? also I am using -1 as a end condetion (teachers choice) while it runs, And I know that the teacher would accept it as its is as the book has no mention of testing input. I do not think its a good ideal to put out software if the user can mess it up by putting a wong input type/
  24. its solaris 10 not linux but I like the new Jave desktop (aka GNOME with java)
  25. I'm going full time and work full time (pplus two kids and a wife.. but who bragging ) I learned 2 things in life. Pain is tempary .. it will stop when you die and when you die there will be pleanty of time for sleep.