+ Post New Thread
Results 1 to 8 of 8
*nix Thread, Help running scripts within scripts in Technical; Sometimes I get really frustrated when the diffs between Linux and MS catch me out I'm trying to automate my ...
  1. #1

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,824
    Thank Post
    1,476
    Thanked 593 Times in 445 Posts
    Rep Power
    168

    Help running scripts within scripts

    Sometimes I get really frustrated when the diffs between Linux and MS catch me out

    I'm trying to automate my eeePC deployment by creating a superscript to run all the things I've put on the wiki
    Auto Connect but I'm bombing out straight away.

    Should this script work

    Code:
    #!/bin/bash
    
    sudo mkdir /mnt/sharename
    sudo chmod 777 /mnt/sharename
    
    sudo cp ./etc/network/if-up.d/nynetstart /etc/network/if-up.d/mynetstart
    
    sudo chmod 777 /etc/network/if-up.d/mynetstart
    
    sudo cp ./home/user/.network-autostart /home/user/.network-autostart
    
    sudo chmod 777 /home/user/.network-autostart
    
    sudo ln -s /mnt/sharename sharename
    I try running it using
    sh ./installnet.sh (which is what is called) (its in /home/user)

    I'm just getting garbage error msgs saying things like ":command not foundne 2:" and then finding there is a folder called sharename? being created in /mnt

    I know I'm missing something fundemental but I can't work out what

    help

    regards

    Simon

  2. #2

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,807
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224
    add this as the second line of your script:
    Code:
    set -x
    Read through the output carefully.

    More info on the 'set' command can be found by typing 'help set' at your nearest console window.

  3. #3
    Gerry's Avatar
    Join Date
    Jun 2007
    Location
    North Wales
    Posts
    431
    Thank Post
    60
    Thanked 38 Times in 35 Posts
    Rep Power
    24
    Quote Originally Posted by SimpleSi View Post
    Code:
    sudo cp ./etc/network/if-up.d/nynetstart /etc/network/if-up.d/mynetstart
    Simon
    Possibly a slight typo in the above line?

  4. #4

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,824
    Thank Post
    1,476
    Thanked 593 Times in 445 Posts
    Rep Power
    168
    @geoff

    As usual - your comments are of no practical use but I'm sure with another 4 hours of work I could get there

    (I just get
    :invalid option line 2: set: -


    Could you not just say in english what I need to do?

    @Gerry - ta for info - it'll come in handy when I get the 1st line working

    regards

    Simon

  5. #5
    Gerry's Avatar
    Join Date
    Jun 2007
    Location
    North Wales
    Posts
    431
    Thank Post
    60
    Thanked 38 Times in 35 Posts
    Rep Power
    24
    Try running the script like this:
    Code:
    sudo ./installnet.sh
    I typed in "help sh" and got
    Code:
    shift: shift [n]
        The positional parameters from $N+1 ... are renamed to $1 ...  If N is
        not given, it is assumed to be 1.
    shopt: shopt [-pqsu] [-o long-option] optname [optname...]
        Toggle the values of variables controlling optional behavior.
        The -s flag means to enable (set) each OPTNAME; the -u flag
        unsets each OPTNAME.  The -q flag suppresses output; the exit
        status indicates whether each OPTNAME is set or unset.  The -o
        option restricts the OPTNAMEs to those defined for use with
        `set -o'.  With no options, or with the -p option, a list of all
        settable options is displayed, with an indication of whether or
        not each is set.

  6. #6

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,824
    Thank Post
    1,476
    Thanked 593 Times in 445 Posts
    Rep Power
    168
    @gerry

    Haven't got access to a machine until tonight but I'm sure I tried sudo ing and got a different error msg but I'll try again )

    I typed in "help sh" and got


    Don't know what you are trying to tell me!

    regards

    Simon

  7. #7
    Gerry's Avatar
    Join Date
    Jun 2007
    Location
    North Wales
    Posts
    431
    Thank Post
    60
    Thanked 38 Times in 35 Posts
    Rep Power
    24
    Ooops! Quite right, doesn't make much sense out-of-context! And it's actually wrong - my initial thought after running "help sh" in a terminal was that it was not Bash but something else. I should have used "man sh" - more descriptive. I'm not a Linux guru, but I have been using Ubuntu now for a few months.

    You don't need to use "sh ./installnet.sh" if you make the script executable. In a terminal type:
    Code:
    sudo chmod +x installnet.sh
    then you can remove the "sh".

    If your script still won't work, paste the full output from the terminal here for us to examine.

  8. #8

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,824
    Thank Post
    1,476
    Thanked 593 Times in 445 Posts
    Rep Power
    168

    Public Apology to Geoff

    @geoff - I'm very very sorry

    I just thought that it would be something simple that someone could easily point out (like need to run as root or something like that )

    And I was tearing my hair out cause I knew it was something simple

    It was.

    I'll make a new post so other pretend @nix geeks son't get caught out like me

    Sorry again

    regards

    Simon

SHARE:
+ Post New Thread

Similar Threads

  1. Printer Scripts
    By FN-GM in forum Scripts
    Replies: 4
    Last Post: 27th December 2007, 02:11 PM
  2. Vista isn't running logon scripts
    By woody in forum Windows Vista
    Replies: 6
    Last Post: 30th January 2007, 03:32 PM
  3. What do you use for your logon scripts.
    By Kyle in forum How do you do....it?
    Replies: 17
    Last Post: 13th October 2006, 07:54 AM
  4. Scripts, Scripts, Scripts
    By wesleyw in forum Windows
    Replies: 18
    Last Post: 17th July 2006, 02:36 PM
  5. Kix Scripts
    By catbert in forum Scripts
    Replies: 5
    Last Post: 27th September 2005, 01:24 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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