Sponsored Content
Top Forums Shell Programming and Scripting Curl not accepting spaces in script via variables Post 303038922 by say170 on Tuesday 17th of September 2019 05:33:44 AM
Old 09-17-2019
tried both ways. removed all my white spaces and tried a variable. Here is a better code stub which shows the full data element.
Code:
...

json_data=$(printf '{"mName":"%s","oName":"%s","lCode":"%s","schema":[{"name": "Fred","RequestId":"1234","Name":"Test","BO":"999999","aId":"%s","keyId":"p1","eId":"Test.ts"}],"cCode":"%s","cCode2":"GB","Url":{"protocol":"http","host":"test.co.uk","port": 1653,"endpoints":[{"name": "requestorEndpoint","value": "mEP"}]}}' "$mName" "$oName" "$lCode" "$aId" "$cCode")



curl --request POST \
  --url http://192.168.1.12:12345/pSvc/config/ps2Req/ \
  --header 'authorization: Bearer '$token   \               <--------- $token comes from further up in the code.
  --header 'content-type: application/json' \
  --silent \
  --data '${json_data}'             <-------- note I had to use single quotes

done < $infile

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

removing spaces from variables?

I stored results like this VAR=`wc -l < ls.txt` But the value of the wc gave me a padded number. How do I strip the padding from $VAR? Do you think I could use SED? Except instead of a file input, have a variable redirection input? (2 Replies)
Discussion started by: yongho
2 Replies

2. Shell Programming and Scripting

invloking another script accepting input

hi I am trying to invoke another application script from my script like --------------------------- main . . ./new appl <<EOF Input 1 Input 2 EOF . . exit ------------------------ But is exits the new application after input command 2, I want that it should not exit and accept... (1 Reply)
Discussion started by: ashish_uiit
1 Replies

3. Shell Programming and Scripting

Spaces in Lines for Variables

All, I am driving myself crazy over this one. I have run a find command against a volume on a nas. That returns a full listing of path and file name. This is an example of one line of output. I redirected the output of the find command to a file. ... (4 Replies)
Discussion started by: bubbwe
4 Replies

4. Shell Programming and Scripting

Passing variables to cli curl

I have a script that uses cli curl, and it would be easier if it was possible to pass variables like this: curl -c $cookie -d $data www.********.comThis doesn't work, instead I have to generate a string and use eval. Is there another, easier way to pass variables to cli curl? (1 Reply)
Discussion started by: locoroco
1 Replies

5. Shell Programming and Scripting

cURL and variables

I have a spent a day with Google trying to figure this one out and have decided its time to ask the experts... I'm running OS X 10.6 I need to use cURL to FTP a file. I have been successful send the file from the command line when I know the filename. My problem is that the filename changes... (2 Replies)
Discussion started by: fmSimplicity
2 Replies

6. Shell Programming and Scripting

script accepting password

Hi friends, I am very new to Unix scripting and having some difficulty in my first shell script. I have written a simple shell script to upload an artifact to a remote machine on the network. echo "Uploading the artifact" scp app.war username@remotemochine.domainname.net:/home/deployables... (3 Replies)
Discussion started by: prashdeep
3 Replies

7. Shell Programming and Scripting

Spaces in variables

I'm having a problem with this.... --------------------------------------------------- #!/bin/bash SPKTAG=" | festival --tts" echo "Welcome to my shell program" "$SPKTAG"; --------------------------------------------------- I have a variable call SPKTAG " | festival --tts" and I... (2 Replies)
Discussion started by: digitalviking
2 Replies

8. Shell Programming and Scripting

Sending awk variables into curl in a bash script

Hello experts! I have a file1 with the following format (yr,day, month, hour,minute): 201201132435 201202141210 201304132030 201410100110 ... What i want to do is to assign variables and then use them in the curl command to download the text of each event from a web page. What I have... (6 Replies)
Discussion started by: phaethon
6 Replies

9. Shell Programming and Scripting

HELP - loop a curl command with different variables from input file

Hi guys! Kind of new to bash scripting and now I'm stuck. I need to curl with these variables: "{ \"nodename\": \"$1\", \"ipaddress\": \"$2\", \"poolname\": \"$3\", \"port\": \"$4\", \"loadbalancer\" : \"$5\" }" and my input_file.txt contains server001 10.10.10.01 serverpool1 80... (4 Replies)
Discussion started by: yort
4 Replies

10. Shell Programming and Scripting

Bash script accepting variables in valid number format

Hi Experts I would like to ask if there is a way to validate if the variable passed is in this kind of sample format "06-10" or "10-01". It was really a challenge to me on how to start and echnically the "6-10" stands for "June 10" and "10-01" stands as "October 1", overall it needs to have ... (3 Replies)
Discussion started by: ersan-poguita
3 Replies
CURLOPT_POSTREDIR(3)					     curl_easy_setopt options					      CURLOPT_POSTREDIR(3)

NAME
CURLOPT_POSTREDIR - how to act on a HTTP POST redirect SYNOPSIS
#include <curl/curl.h> CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTREDIR, long bitmask); DESCRIPTION
Pass a bitmask to control how libcurl acts on redirects after POSTs that get a 301, 302 or 303 response back. A parameter with bit 0 set (value CURL_REDIR_POST_301) tells the library to respect RFC 7231 (section 6.4.2 to 6.4.4) and not convert POST requests into GET requests when following a 301 redirection. Setting bit 1 (value CURL_REDIR_POST_302) makes libcurl maintain the request method after a 302 redirect whilst setting bit 2 (value CURL_REDIR_POST_303) makes libcurl maintain the request method after a 303 redirect. The value CURL_REDIR_POST_ALL is a convenience define that sets all three bits. The non-RFC behaviour is ubiquitous in web browsers, so the library does the conversion by default to maintain consistency. However, a server may require a POST to remain a POST after such a redirection. This option is meaningful only when setting CURLOPT_FOLLOWLOCATION(3). DEFAULT
0 PROTOCOLS
HTTP(S) EXAMPLE
CURL *curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); /* a silly POST example */ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data=true"); /* example.com is redirected, so we tell libcurl to send POST on 301, 302 and 303 HTTP response codes */ curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL); curl_easy_perform(curl); } AVAILABILITY
Added in 7.17.1. This option was known as CURLOPT_POST301 up to 7.19.0 as it only supported the 301 then. CURL_REDIR_POST_303 was added in 7.26.0. RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. SEE ALSO
CURLOPT_FOLLOWLOCATION(3), CURLOPT_POSTFIELDS(3), libcurl 7.54.0 February 03, 2016 CURLOPT_POSTREDIR(3)
All times are GMT -4. The time now is 04:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy