Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Writing a (slightly) simple compilation script

  1. #11
    Join Date
    Aug 2005
    Location
    USA
    Beans
    378
    Distro
    Kubuntu 10.10 Maverick Meerkat

    Re: Writing a (slightly) simple compilation script

    i still get the same thing whether i add the spaces in or not:

    Code:
    compile: 47: [[: not found
    compile: 76: [[: not found
    Code:
    #!/bin/bash
    clear
    echo "version of keytouch? "
    #read keytouch_version
    keytouch_version="2.4.1"
    
    echo "version of keytouch editor? "
    #read editor_version
    editor_version="3.2.0-beta"
    
    echo "extract tarballs?"
    read decision
    echo ""
    
    if [[ "$decision" == y]]; then
    
    	tar xvf keytouch-$keytouch_version.tar.gz
    	tar xvf	keytouch-editor-$editor_version.tar.gz
    	echo ""
    
    	#compiles and installs keytouch
    	cd keytouch-$keytouch_version
    	./configure
    	make -s
    	sudo make -s install
    	echo ""
    
    	cd keytouch-config
    	./configure
    	make -s
    	sudo make -s install
    	echo ""
    
    	cd ../keytouch-keyboard
    	./configure
    	make -s
    	sudo make -s install
    	echo ""
    
    	#compiles and installs the keytouch editor
    	cd ../../keytouch-editor-$editor_version
    	./configure
    	make -s
    	sudo make -s install
    	echo ""
    
    fi
    
    if [[ "$decision" == n]]; then
    	#compiles and installs keytouch
    	cd 'keytouch-$keytouch_version'
    	./configure
    	make -s
    	sudo make -s install
    	echo ""
    
    	cd keytouch-config
    	./configure
    	make -s
    	sudo make -s install
    	echo ""
    
    	cd ../keytouch-keyboard
    	./configure
    	make -s
    	sudo make -s install
    	echo ""
    
    
    	#compiles and installs the keytouch editor
    	cd ../../keytouch-editor-$editor_version
    	./configure
    	make -s
    	sudo make -s install
    	echo ""
    fi
    for the other thing i want to be able to pass "own" the path in the same line, pretty much how you would do with any other command that requires a path, such as chown [user][path] or chgrp [group] [path]

  2. #12
    Join Date
    Jun 2006
    Location
    Gwangju, Korea
    Beans
    3,479

    Re: Writing a (slightly) simple compilation script

    I ran your code as posted, except that I put echo before all your compilation stuff since I don't have those files on my machine. With the spaces missing (as in your post--you still haven't added them as required), I get the following output:
    Code:
    ~:$ ./test.sh 
    version of keytouch? 
    version of keytouch editor? 
    extract tarballs?
    y
    
    ./test.sh: line 15: syntax error in conditional expression: unexpected token `;'
    ./test.sh: line 15: syntax error near `;'
    ./test.sh: line 15: `if [[ "$decision" == y]]; then'
    When I add a space where required (hint: after the y in the error above), it works fine.

    Your error message looks like you aren't running bash. Are you sure you're running the code as you posted? You aren't doing something silly like
    Code:
    sh your_script
    are you? That would produce the error you're getting.

    If you add in the spaces I've mentioned multiple times, your script works. One suggestion, though. Why check for $decision == y then later for $decision == n? Why not use an else for the second case? It would make your code clearer.
    Quote Originally Posted by Brando569 View Post
    for the other thing i want to be able to pass "own" the path in the same line, pretty much how you would do with any other command that requires a path, such as chown [user][path] or chgrp [group] [path]
    See my previous post for the answer to this question.

  3. #13
    Join Date
    Aug 2005
    Location
    USA
    Beans
    378
    Distro
    Kubuntu 10.10 Maverick Meerkat

    Re: Writing a (slightly) simple compilation script

    Quote Originally Posted by mssever View Post
    Your error message looks like you aren't running bash. Are you sure you're running the code as you posted? You aren't doing something silly like
    Code:
    sh your_script
    are you? That would produce the error you're getting.
    guilty as charged... i changed the permissions on it and executed it and it worked perfectly. thanks for all your help!

    If you add in the spaces I've mentioned multiple times, your script works. One suggestion, though. Why check for $decision == y then later for $decision == n? Why not use an else for the second case? It would make your code clearer.[/QUOTE]

    i tried to do that but then i changed it for some reason

  4. #14
    Join Date
    Jun 2006
    Location
    Gwangju, Korea
    Beans
    3,479

    Re: Writing a (slightly) simple compilation script

    Quote Originally Posted by Brando569 View Post
    guilty as charged... i changed the permissions on it and executed it and it worked perfectly. thanks for all your help!
    If you had called it as bash your_script, it would have worked. Basically, you can forget that sh exists (except for a few specific situations) and just use bash.

  5. #15
    Join Date
    Aug 2005
    Location
    USA
    Beans
    378
    Distro
    Kubuntu 10.10 Maverick Meerkat

    Re: Writing a (slightly) simple compilation script

    another lesson learned. ive always wondered this, whats the difference between running a script with sh and ./ ?

    edit: the other thing that i wanted works.... mostly. for some reason chgrp can red the variable but chown cant

    Code:
    path="$1"; sudo chown -vR bran $path; sudo chgrp -vR bran $path
    Last edited by Brando569; August 2nd, 2008 at 11:31 PM.

  6. #16
    Join Date
    Jun 2006
    Location
    Gwangju, Korea
    Beans
    3,479

    Re: Writing a (slightly) simple compilation script

    Quote Originally Posted by Brando569 View Post
    another lesson learned. ive always wondered this, whats the difference between running a script with sh and ./ ?
    When you run your script directly (such as ./), the kernel examines the shebang line to find an interpreter. It then calls the interpreter named with the path to your script as its argument. When you explicitly call an interpreter, the interpreter simply evaluates the file as it sees fit. Shebang lines are comments, so they get ignored.

    edit: the other thing that i wanted works.... mostly. for some reason chgrp can red the variable but chown cant

    Code:
    path="$1"; sudo chown -vR bran $path; sudo chgrp -vR bran $path
    I'm not sure I understand what you mean when you say that chgrp can't read the variable. However, be sure to out all variable references in double quotes. Otherwise, if someone passes in a path that contains spaces, your script will break.
    Code:
    path="$1"
    sudo chown -vR bran:bran "$path" # you can set both owner and group in a single command

  7. #17
    Join Date
    Aug 2005
    Location
    USA
    Beans
    378
    Distro
    Kubuntu 10.10 Maverick Meerkat

    Re: Writing a (slightly) simple compilation script

    thanks for the explanation and i never knew you could do both user and group in one command, ive been doing them seperate for years! it works now and what i meant before was that when i would run the script it would say that chown was missing an arugment after bran (the path) yet chgrp wouldnt complain of anything.
    Last edited by Brando569; August 3rd, 2008 at 03:42 AM.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •