how to add a wildcard to an xmlstarlet update - attributes

This xmlstartlet update works for "ThreadGroup" but not for "fooThreadGroup" how can I add a prefix wildcard to the string "ThreadGroup" in the following please?
xmlstarlet ed --inplace --update '//ThreadGroup/longProp[#name="ThreadGroup.start_time"]' --value '1363247040000' "${xmlFile}"

Since xmlstarlet doesn't support ends-with() (because that's XPath 2.0), you'd have to do something like:
//*[self::ThreadGroup or self::fooThreadGroup]/longProp[#name="ThreadGroup.start_time"]

Related

zsh: no matches found when $ curl -s -X localhost:60702/api/bundle?name=light%20reading | j q '.'

I am working through the Node.js The Right Way book by Jim Wilson. I am currently trying to use a PUSH request to create a new bundle with the specified name.
* curl -X POST http://:/api/bundle?name=
However, when I use the command:
$ curl -s -X POST localhost:60702/api/bundle?name=light%20reading | jq '.'
rather than getting the JSON indicating that a Bundle has been created, I get: zsh: no matches found: localhost:60702/api/bundle?name=light%20reading
The command should be using a POST request to create a new All of my code is bit for bit identical to the code listed in the book. Any ideas?
Can you try
curl -s -X POST 'localhost:3000/api/bundle?name=light%20reading'
i.e wrap the url within '
This seems to be an issue with zsh solved here.
There are several ways to solve this:
You can escape the question mark ? in the url by quoting the url as explained by #huzaifa-saifuddin to avoid zsh treating it as a wildcard character.
As explained here, you can create an alias for curl: alias curl='noglob curl'
As explained here, you can disable to nomatch handling by adding the following to your ~/.zshrc: unsetopt nomatch

Linux-wget command

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

Makefile:3: *** missing separator. Stop

I have attempted what I could, with the answers found on StackOverflow on this question. I do not believe the issue is with tabs. Here is the makefile:
# $OpenBSD: Makefile,v 1.15 2010/02/09 08:55:31 markus Exp $
.include <bsd.own.mk>
SUBDIR= lib ssh sshd ssh-add ssh-keygen ssh-agent scp sftp-server \
ssh-keysign ssh-keyscan sftp ssh-pkcs11-helper
distribution:
${INSTALL} -C -o root -g wheel -m 0644 ${.CURDIR}/ssh_config \
${DESTDIR}/etc/ssh/ssh_config
${INSTALL} -C -o root -g wheel -m 0644 ${.CURDIR}/sshd_config \
${DESTDIR}/etc/ssh/sshd_config
.include <bsd.subdir.mk>
I have attempted to put a tab before line 3 (where the issue is), and had the following error appear:
Makefile:3: *** commands commence before first target. Stop.
This isn't a makefile of my own design--it was downloaded directly from here:
http://www.openssh.com/openbsd.html
(first download link)
Additionally, based on another answer to this question, I have used the following command:
root#server:/usr/src/ssh# cat -e -t -v Makefile
which output the following:
\#^I$OpenBSD: Makefile,v 1.15 2010/02/09 08:55:31 markus Exp $$ $ .include <bsd.own.mk>$ $ SUBDIR=^Ilib ssh sshd ssh-add ssh-keygen
ssh-agent scp sftp-server \$ ^Issh-keysign ssh-keyscan sftp
ssh-pkcs11-helper$ $ distribution:$ ^I${INSTALL} -C -o root -g wheel
-m 0644 ${.CURDIR}/ssh_config \$ ^I ${DESTDIR}/etc/ssh/ssh_config$ ^I${INSTALL} -C -o root -g wheel -m 0644 ${.CURDIR}/sshd_config \$ ^I
${DESTDIR}/etc/ssh/sshd_config$ $ .include <bsd.subdir.mk>$
Does anyone know what could be the issue? Thanks in advance.
This makefile is written for BSD make. You're trying to run it with GNU make. They use different formats.
In particular, the .include command is not valid in GNU make.
Since you've tagged your question with "linux", I assume you're using Linux and not OpenBSD. The ssh version you want for Linux is the portable one, but it seems you downloaded the OpenBSD-specific one. Try http://www.openssh.com/portable.html . See the openssh front page for details on the OpenBSD/portable split releases.
Check your /etc/vimrc or /etc/virc, Comment out the set expandtab
"set expandtab " Always uses spaces instead of tab characters (et)
Using tab reedit the Makefile file. You can look also see the keywords missing separator by info make, you will see:
`missing separator. Stop.'
`missing separator (did you mean TAB instead of 8 spaces?). Stop.'
This means that `make' could not understand much of anything about
the makefile line it just read. GNU `make' looks for various
separators (`:', `=', recipe prefix characters, etc.) to indicate
what kind of line it's parsing. This message means it couldn't
find a valid one.
One of the most common reasons for this message is that you (or
perhaps your oh-so-helpful editor, as is the case with many
MS-Windows editors) have attempted to indent your recipe lines
with spaces instead of a tab character. In this case, `make' will
use the second form of the error above. Remember that every line
in the recipe must begin with a tab character (unless you set
`.RECIPEPREFIX'; *note Special Variables::). Eight spaces do not
count. *Note Rule Syntax::.

dates in couchdb

How do you insert dates in couchdb? As strings?
I have couchdb-1.0.3.
1.
I did this:
$ curl -X PUT 127.0.0.1:5984/misc/doc1 -d '{"date":"2011-13-01T17:30:12+01:00"}'
This works, but this date doesn't exists.
2.
I thought I had to do this:
$ curl -X PUT 127.0.0.1:5984/misc/doc1 -d '{"date":new Date("2011-12-01)}'
But this is invalid JSON.
3.
When I use this format,
$ curl -X PUT 127.0.0.1:5984/misc/doc1 -d '{"date":"2011/12/01 00:00:00"}'
I doesn't work well with this format
$ curl -X GET '127.0.0.1:5984/misc/_design/foo/_view/view1?startkey="2012-02-02"'
Because the document shows up in the result.
Thanks,
Eric J.
I suggest that you use your first format, or possibly the JSON2 standard format, which is most convenient for JavaScript. That is what most people do, and it works well with your example request:
$ curl '127.0.0.1:5984/misc/_design/foo/_view/view1?startkey="2012-02-02"'
To validate your data, use a validation function.

How do I POST LF with curl command line tool?

I'm trying to POST to the HTTP gateway of an SMS provider (Sybase 365) using CURL from a Linux shell script.
I need to pass the following data (note the [ ] and LF characters)
[MSISDN]
List=+12345678
[MESSAGE]
Text=Hello
[END]
If I submit a file using the -F parameter, CURL removes the LF e.g.
curl -F #myfile "http://www.sybase.com/..."
results in this at the server (which is rejected)
[MSISDN]List=+12345678[MESSAGE]Text=Hello[END]
Is there anything I can do to avoid this or do I need an alternative tool?
I'm using a file containing my data for testing but I'd like to avoid that in practice and POST directly from the script.
Try using --data-binary instead of -d(ata-ascii).
From the manual:
--data-binary (HTTP) This posts data in a similar manner as --data-ascii does, although when using this option the entire context of the posted data is kept as-is.
If you want to post a binary file without the strip-newlines feature of the --data-ascii option, this is for you. If this option is used several times, the ones following the first will append data.
ETA: oops, I should read the question more closely. You're using -F, not -d. But --data-binary may be still be worth a shot.
Probably a silly thought, but I don't suppose it actually requires CRLF instead of just LF?
Alternatively, have you tried using the --data-binary option instead of -F?
I've got this working using -d
request=`printf "[MSISDN]\nList=$number\n[MESSAGE]\nText=$message\n[END]\n"`
response=`curl -s -u $username:$password -d "$request" http://www.sybase.com/...`
Curiously, if I use -d #myfile (where myfile contains LF separated text), it doesn't work.
I also tried --data-binary without success.
curl "url" --data-binary #myfile
posts new lines in the data [tested on curl 7.12.1]

Resources