I have a set of comman-line tools that I implement as bash functions, eg:
function sf
{
sftp $(svr $1)
}
where svr is another function that translates a short name to a fully qualified domain name. I got the idea that I wanted to convert this function:
function irpt
{
~/tools/icinga_report $*
}
to something like:
function irpt
{
python <<!
import requests
...lots of python stuff...
!
}
This works perfectly, except for one thing: I need to add the parameters somewhere, but I can't see where. I have tried to enclose the whole python block in { }, but it doesn't work:
function irpt
{
python <<!
import requests
...lots of python stuff...
!
}
The shell doesn't accept the definition:
-bash: /etc/profile: line 152: syntax error near unexpected token `$*'
-bash: /etc/profile: line 152: `} $*'
Is there any way to implement this? ===EDIT=== Inspired by the answer I accepted, this is what I did, maybe it is useful for others:
function irpt
{
python <<!
import requests
param="$*".split(' ')
...lots of python stuff...
!
}
This works beautifully.