Re: Bash function from psql (v14)

From: "Efrain J(dot) Berdecia" <ejberdecia(at)yahoo(dot)com>
To: mnunna(at)fnal(dot)gov, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Bash function from psql (v14)
Date: 2024-11-09 18:02:03
Message-ID: 1239230547.604518.1731175323447@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Maybe try using full path...

Yahoo Mail: Search, Organize, Conquer

On Sat, Nov 9, 2024 at 12:41 PM, Murthy Nunna<mnunna(at)fnal(dot)gov> wrote:
<!--#yiv2777555521 filtered {}#yiv2777555521 filtered {}#yiv2777555521 p.yiv2777555521MsoNormal, #yiv2777555521 li.yiv2777555521MsoNormal, #yiv2777555521 div.yiv2777555521MsoNormal {margin:0in;font-size:11.0pt;font-family:"Calibri", sans-serif;}#yiv2777555521 span.yiv2777555521EmailStyle17 {font-family:"Calibri", sans-serif;color:windowtext;font-weight:normal;font-style:normal;}#yiv2777555521 .yiv2777555521MsoChpDefault {}#yiv2777555521 filtered {}#yiv2777555521 div.yiv2777555521WordSection1 {}-->
Hi,

 

I am trying to code bash function and call it from psql. But it is failing. How can I get this to work. Creating a separate script instead of a function works, but I do not want to do that. I have too many variables to be passed back and forth. Any ideas?

 

#!/bin/bash

psql -d postgres  -p 5433 <<-PSQLBLOCK

\! run-bash-function                                        -- This doesn’t work

PSQLBLOCK

 

# Run the function outside PSQLBLOCK. This works!

run-bash-function

exit $?

 

# Create bash function

run-bash-function ()

{

  echo "in bash function"

}

# end of bash script

 

 

Run the above script:

./test-bash-function.sh

sh: line 1: run-bash-function: command not found

in bash function

 

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vijaykumar Jain 2024-11-09 18:22:04 Re: Bash function from psql (v14)
Previous Message Murthy Nunna 2024-11-09 17:41:02 Bash function from psql (v14)