Article 5N745 [SOLVED] Script to trigger second script--second script gets arguments of first script

[SOLVED] Script to trigger second script--second script gets arguments of first script

by
keif
from LinuxQuestions.org on (#5N745)
Hello all, I was hoping to get some advice on a question I have about bash scripting and Linux.

I have two scripts. scriptOne.sh takes arguments when ran on the command line, and executes scriptTwo.sh

scriptOne.sh
Code:#!/bin/bash

#get version of scriptTwo.sh using arguments
#
if [[ $# -eq 0 ]]; then
r="releases"
v="RELEASE"
else
if [[ $# -eq 1 ]]; then
if [ "$1" == "snapshot" ]; then
r="snapshots"
v="LATEST"
else
r="releases"
v=$1"-RELEASE"
fi
else
r="snapshots"
v=$2"-SNAPSHOT"
fi
fi

# use arguments to download correct version of scriptTwo.sh from repo
#
url="https://downloads.example-repo.net/nexus/service/local/artifact/maven/redirect?r="$r"&g=com.mycompany.mysoftware&a=myapp&p=zip&v="$v

curl -fsSL -u ${user}:${password} "${url}" -o /root/scripts/scriptTwo.sh

/root/scripts/scriptTwo.shExample of running scriptOne.sh on the command line:

Code:./scriptOne.sh snapshot 1.0.2.7If possible, I want to have scriptTwo.sh use the arguments from scriptOne.sh. I cannot edit scriptOne.sh and pass them into scriptTwo.sh because it would involve an image update, which I am trying to avoid. I can, however, edit scriptTwo.sh because I get it from the repo.

in scriptTwo.sh I have tried to use .bash_history or run the history command. And also tried using fc but none of that works.

I am running Ubuntu 18.04

Is there any way scriptTwo.sh can get the argument data from scriptOne.sh without editing scriptOne.sh?

Any advice is appreciated. Thank youlatest?d=yIl2AUoC8zA latest?i=0iVD36JfK3k:JIKhRIy3eyo:F7zBnMy latest?i=0iVD36JfK3k:JIKhRIy3eyo:V_sGLiP latest?d=qj6IDK7rITs latest?i=0iVD36JfK3k:JIKhRIy3eyo:gIN9vFw0iVD36JfK3k
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments