Reputation: 4028
Fairly new to the world of UNIX and trying to get my head round its quirks.
I am trying to make a fairly simple shell script that uses wGet to send a XML file that has been pre-processed with Sed .
I thought about using a pipe but it caused some weird behaviour where it just outputted my XML into the console.
This is what I have so far:
File_Name=$1
echo "File name being sent to KCIM is : " $1
wget "http://testserver.com" --post-file `sed s/XXXX/$File_Name/ < template.xml` |
--header="Content-Type:text/xml"
From the output I can see I am not doing this right as its creating a badly formatted HTTP request
POST data file
<?xml' missing: No such file or directory Resolving <... failed: node name or service name not known. wget: unable to resolve host address
<'
Bonus points for explaining what the problem is as well as solution
Upvotes: 0
Views: 1005
Reputation: 182619
For wget
the option post-file
sends the contents of the named file. In your case you seem to be passing directly the data so you probably want --post-data
.
The way you are doing it right now, bash
gets the output from sed
and wget
gets something like:
wget ... --post-file <?xml stuff stuff stuff
So wget
goes looking for a file called <?xml
instead of using that text verbatim.
Upvotes: 3