micha / resty

Little command line REST client that you can use in pipelines (bash or zsh).
MIT License
2.65k stars 143 forks source link

POST/GET command not found when used in Bash script #84

Open benbelgium opened 6 years ago

benbelgium commented 6 years ago

Hi Micha

First of all thank you for developing resty.

I'm trying to write a bash file to automatically execute some steps, but if I execute each command in a terminal everything works fine, but in bash all my POST/GET commands fail with the message command not found....

I read up online about PATH settings that could be causing this, I read on github the examples and everything seems perfect to me, and still it's not working....

#!/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

source /sbin/resty 'http://abu/api'

POST /login '{"username" : "report", "password" : "XXXXXXXX"}' | jshon -e auth_token -u

I added the PATH manually just to make sure it's correct, and for security reasons I replaced the real password with XXXX If I would execute ./checkben.sh the output would be:

./checkben.sh: line 11: POST: command not found warning: nothing to read

If I would execute each command manually at the terminal the output would be:

djA6MDUwNzc3MzMtZjg5OC00YTdiLWI2OGQtNGUzMDgzMjg5ODVhOjM3Oi91c3IvYnAvbG9ncy5kaXIvZ3VpX3JlcG9ydC5sb2c6MA==

Which is EXACTLY what I needed, so it is working fine at the terminal prompt....

broerman commented 5 years ago

Try to expand aliases in the shell. This works for me.

#!/bin/bash
shopt -s expand_aliases

Bernd