Linux-wget command - linux

I need a quick help on customizing my wget command in a shell script:
The wget command looks something like this:
wget http://infamvn:8081/nexus/content/groups/LDM_REPO_LIN64/com/infa/com.infa. products.ldm.ingestion.server.scala/10.0.0.135.527-SNAPSHOT/com.infa.products.ldm.ingestion.server.scala-10.0.0.135.527-20150622.210643-1-sources.jar
Here I'd like to add the 10.0.0.135.527 in a variable, so I created a script something like this:
n = 10.0.0.135.527
wget http://infamvn:8081/nexus/content/groups/LDM_REPO_LIN64/com/infa/com.infa.products.ldm.ingestion.server.scala/"$n"-SNAPSHOT/com.infa.products.ldm.ingestion.server.scala-"$n"-20150622.210643-1-sources.jar
but this is not working, any idea what's wrong here?

Try this to create a string variable n, with no leading whitespace (thanks #011c):
n="10.0.0.135.527"
wget http://infamvn:8081/nexus/content/groups/LDM_REPO_LIN64/com/infa/com.infa.products.ldm.ingestion.server.scala/"$n"-SNAPSHOT/com.infa.products.ldm.ingestion.server.scala-"$n"-20150622.210643-1-sources.jar

Related

How to append a variable to CURL command

I am trying to use curl qrenco.de/google.com with an alias so that the alias takes the input parameter google.com and appends it to curl qrenco.de/. i want it to look something like this:
$qrcode google.com
i have tried the following:
alias qrcode='curl qrenco.de/$(read)'
but this doesn't seem to work. i am new to bash and would like to know the right approach.
Almost every time an alias gives you trouble, you should just be using a function.
qrcode() { curl qrenco.de/"$1"; }

Concatinating paths in bash (.sh) resolves in path with '$'\r''

I get a string from a command that lokos like the following:
part1=$(pip install numpy 2>&1)
part1 has stored some variable like: c:\programdata\anaconda3\lib\site-package
Now I want to append "numpy" to it. To do so I tried it with:
part1+=/numpy
and every other solution listed here:
How to concatenate strings in bash
However the output looks like this: 'c:\programdata\anaconda3\lib\site-packages'$'\r''/numpy'
What do I have to do to get rid of this effect?
I am using Windows10 and scripting .sh files.
You can use:
part1="${part1/$'\r'}/numpy"
Here "${part1/$'\r'} replaces \r by an empty string. $'\r' is special bash construct to enter escape sequences.

Assign Linux Command to Variable in Groovy

I'm attempting to run a linux command, curl, through groovy, and would like the output to be assign to a variable. I'd like to do this, so I can extract specific data from the curl output, and use in in m y groovy script.
Any ideas, how I can do this.
I've tried,
def after = "curl \"https://test.com\"".execute()
def after = "curl \"https://test.com\"".execute().text
but the variable is always empty. Any help would be appreciated.
linux command with spaces needs to be separated.
["/bin/sh", "-o", "your_command"].execute()
In your case it would be something like below:
["curl", "https://test.com"].execute()
OR
def after = ["curl", "https://test.com"].execute().text
Try and see if it works.

Usage of Wget for a long URL

I am trying to download a file with the below URL:
wget http://example.com/reports/downloadreport?roleId=8&loginName=9011613&code=123
But it takes only till
http://example.com/reports/downloadreport?roleId=8
not sending the remaining things. I need to send at least role ID and loginName to get the file.
I tried to create a shell script like below, but that is not working either:
i="http://euroams.eurekaforbes.co.in:8080/efms/reports/bamsinvoiceresultdownload?roleId=8&loginName=9011613"
wget --tries=45 -i $i
How can I fix this?
Enclose the URL in quotes. Your shell is interpreting the "&" rather than passing it as a parameter, so it's seeing what you typed as the following (three commands rather than one):
wget http://example.com/reports/downloadreport?roleId=8 &
loginName=9011613 &
code=123

How to make separate strings of a variant in shell script

#! /bin/sh
VAR=(fdf fef fef)
for i in ${VAR}; do
echo i;
done
Code above has errors. I want to make shell take VAR as a separate string array, and get the output like this:
fdf
fef
fef
how to make it happen ? Thanks !
Try this:
VAR=(aa bb cc)
for i in "${VAR[#]}"
do
echo $i;
done
More info in this article.
The proposed solution only works when using bash. He must also have changed or removed the shebang, otherwise you'll get: syntax error: unexpected "(".
See also his follow up question: How come using ./shell.sh get error but . shell.sh works

Resources