0

I would like to find a way of creating a bash script (scripts.sh) which will execute different Python and Go scripts inside of itself.

What I want to do is something like this:

#!/bin/bash
URL="https://google.com"    
bash scripts.sh URL

which would append the URL parameter to all the scripts called inside the bash script itself.

Let's say I have 2 python scripts and 2 Go scripts to call within the bash with that same parameter coded-in.

python3 script1.py -u URL
python3 script2.py -d URL
goscript -domain URL
goscript2 -d URL

Any ideas on how to achieve this?

1
  • Can you provide some additional informations? Have you tried to insert the 4 lines in your bash script? Commented Nov 5, 2020 at 12:08

1 Answer 1

1

You are close. Use the URL variable to call your other commands. Like this, in a single script:

#!/bin/bash
URL="https://google.com"    

python3 script1.py -u $URL
python3 script2.py -d $URL
goscript -domain $URL
goscript2 -d $URL

To call scripts.sh, you can do it like this:

./scripts.sh 

If you want a wrapper script to define the URL value, you could to this:

  • wrapper.sh

    #!/bin/bash
    URL="https://example.com"
    scripts.sh $URL
    
  • scripts.sh

    #!/bin/bash
    URL="$1"
    
    python3 script1.py -u $URL
    python3 script2.py -d $URL
    goscript -domain $URL
    goscript2 -d $URL
    

Add to this some verifications (ex. number of arguments is ok, URL is a valid url format, ...). What I posted is to demonstrate the idea, not a full "production" ready script.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.