+ Reply to Thread
Posts 1 to 4 of 4
  1. #1

    TykeLike

    SimonMac's Avatar
    Join Date
    Aug 2010
    Location
    God's Own Republic Of Yorkshire
    Posts
    21,800
    Thanks (Given)
    220
    Thanks (Received)
    994
    Likes (Given)
    785
    Likes (Received)
    2769

    Default Shell Script Help

    If this was windows I could knock this out in seconds, but it's linux and I haven't much experience, or more to the point examples that I reverse engineer and rip off

    I have two variables say "name" and "location"

    What I want to be able to to is create a script that will allow me to pick one from each pre-determined list and then use them in a series of file paths to then move them to a single place

    Code:
    Source\%name%\%1%\filename1
    Source\%name%\%2%\filename2
    Source\%name%\%3%\filename3
    
    Source\%location%\%a%\filename2
    Source\%location%\%b%\filename2
    Source\%location%\%c%\filename2
    
    cp source\%var1%\filename1 destination\filename1
    cp source\%var2%\filename2 destination\filename2
    
    ./destination/run.sh
    Firstly does the ask make sense?
    “Live a good life. If there are gods and they are just, then they will not care how devout you have been, but will welcome you based on the virtues you have lived by. If there are gods, but unjust, then you should not want to worship them. If there are no gods, then you will be gone, but will have lived a noble life that will live on in the memories of your loved ones.”

    ― Marcus Aurelius

  2. #2

    Super poster


    Join Date
    Jan 2009
    Posts
    2,990
    Thanks (Given)
    138
    Thanks (Received)
    63
    Likes (Given)
    737
    Likes (Received)
    354

    Default

    Quote Originally Posted by SimonMac View Post
    If this was windows I could knock this out in seconds, but it's linux and I haven't much experience, or more to the point examples that I reverse engineer and rip off

    I have two variables say "name" and "location"

    What I want to be able to to is create a script that will allow me to pick one from each pre-determined list and then use them in a series of file paths to then move them to a single place

    Code:
    Source\%name%\%1%\filename1
    Source\%name%\%2%\filename2
    Source\%name%\%3%\filename3
    
    Source\%location%\%a%\filename2
    Source\%location%\%b%\filename2
    Source\%location%\%c%\filename2
    
    cp source\%var1%\filename1 destination\filename1
    cp source\%var2%\filename2 destination\filename2
    
    ./destination/run.sh
    Firstly does the ask make sense?
    Still need a hand with this? If so PM me.

  3. #3

    TykeLike

    SimonMac's Avatar
    Join Date
    Aug 2010
    Location
    God's Own Republic Of Yorkshire
    Posts
    21,800
    Thanks (Given)
    220
    Thanks (Received)
    994
    Likes (Given)
    785
    Likes (Received)
    2769

    Default

    Quote Originally Posted by bobspud View Post
    Still need a hand with this? If so PM me.
    Yep, will do!
    “Live a good life. If there are gods and they are just, then they will not care how devout you have been, but will welcome you based on the virtues you have lived by. If there are gods, but unjust, then you should not want to worship them. If there are no gods, then you will be gone, but will have lived a noble life that will live on in the memories of your loved ones.”

    ― Marcus Aurelius

  4. #4

    TykeLike

    SimonMac's Avatar
    Join Date
    Aug 2010
    Location
    God's Own Republic Of Yorkshire
    Posts
    21,800
    Thanks (Given)
    220
    Thanks (Received)
    994
    Likes (Given)
    785
    Likes (Received)
    2769

    Default

    No idea if this is the most elegant way but it seems to work so far

    Code:
    #!/bin/bash
    # Bash Menu Script Example
    
    folder=/home/simonmac
    
    auths=(name1 name2 name3 name4 name5 name6)
    select auth in "${auths[@]}"; do
       cp $folder/auth/$auth/auth.json $folder/AppName/configs/auth.json
       break
    done
    
    configs=(config1 config2 config3)
    select config in "${configs[@]}"; do
        cp $folder/configs/$config/config.json $folder/AppName/configs/config.json
        break
    done
    
    ./AppName/run.sh
    “Live a good life. If there are gods and they are just, then they will not care how devout you have been, but will welcome you based on the virtues you have lived by. If there are gods, but unjust, then you should not want to worship them. If there are no gods, then you will be gone, but will have lived a noble life that will live on in the memories of your loved ones.”

    ― Marcus Aurelius

Posting Permissions

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

Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.