param(
[string]$pod,
[string]$username,
[string]$pass,
[string]$environment,
[string]$delay,
[string]$utype,
[string]$etype,
[string]$url
)
$cmd = "protactor " + $f.name + " ";
if($pod -ne ""){
$cmd+=" --params.pod=$pod";
}
if($username -ne ""){
$cmd+=" --params.user=$username";
}
if($pass -ne ""){
$cmd+=" --params.pass=$pass"
}
if($utype -ne ""){
$cmd+=" --params.type=$utype"
}
if($url -ne ""){
$cmd+=" --params.url=$url"
}
if($etype -ne ""){
$cmd+=" --params.type=$etype"
}
$cmd
Invoke-Expression -Command:$cmd
is there a way to convert above powershell script to bash script? thank you so much, much appreciated
I have done something like this but I am unable to build command dynamically and invoke it at the end like in powershell, my question is can I build a command dynamically if an argument is not passed, I don't want that to be included in the command, for example if I don't pass '-p xxx' then I don't want '--params.pass=$password' show up in the command in bash.
#!/bin/bash
# how to use
# ./protactor-batch.sh -e xxx -u xxx -p xxx
while getopts u:p:e:s: flag
do
case "${flag}" in
u) username=${OPTARG};;
p) password=${OPTARG};;
e) pod=${OPTARG};;
s) sec=${OPTARG};;
esac
done
protractor $f --params.pod=$pod --params.user=$username --params.pass=$password