I have worked my best on trying to make a script to iterate thorughthrough 2 Arraysarrays.
The values in each Arrayarray needs to get its value input into a string called ExecuteSyncoid based on a string called SyncoidCommand so a command with the changed parts will be executed.
The String is called
SyncoidCommand
The command/string from SyncoidCommand that needs to be changed looks like this
SynCoid-IterateThroughDataSets.sh -s /home/darkyere/Scripts/Syncoid/shortsourcelist -d /home/darkyere/Scripts/Syncoid/shortdestinationlist -c "syncoid <username>@XXX.XXX.XXX.XXX:SourceDataSet DestDataSet --compress none --sshcipher [email protected] --sshport <Port> --sshkey "/Dest/To/KeyFile" --no-privilege-elevation" -p <Password>
Now the two parts that needs to be changed is in
<username>@XXX.XXX.XXX.XXX:SourceDataSet DestDataSet
Where SourceDataSet and DestDataSet is the two in question.
It will in the long run allso need to work in the Opposite way looking like this
SourceDataSet <username>@XXX.XXX.XXX.XXX:DestDataSet
I have tried these different ways And few more i didnt keep in my attempts
The
$SourcePath
# And
$DestPath
Is the value from the two arrays i am attempting to insert into "ExecuteSyncoid"
ExecuteSyncoid="${SyncoidCommand/SourceDataSet/$SourcePath}"
ExecuteSyncoid="${SyncoidCommand/DestDataSet/$DestPath}"
# ----------
ExecuteSyncoid=$(echo $SyncoidCommand | sed "s+SourceDataSet+$SourcePath+g")
ExecuteSyncoid=$(echo $SyncoidCommand | sed "s+DestDataSet+$DestPath/+g")
But the changed string allways resembles something like
syncoid <username>@XXX.XXX.XXX.XXX:SourceDataSet Storage/WallaBag --compress none --sshcipher [email protected] --sshport <Port> --sshkey "/Dest/To/KeyFile" --no-privilege-elevation" -p <Password>
So the code changes DestDataset without a problem.
But in all my attempts including more than i posted it never changes the
<username>@XXX.XXX.XXX.XXX:SourceDataSet
To etc.
<username>@XXX.XXX.XXX.XXX:Storage/WallaBag
Is there anyone out there with some bash knowledge that can help me change the part of the string with ":" in it No matter if it is
<username>@XXX.XXX.XXX.XXX:SourceDataSet DestDataSet
# Or
SourceDataSet <username>@XXX.XXX.XXX.XXX:DestDataSet
Best Regards, And thank you for reading Darkyere