Facing issue in Shell while executing query on remote postgres database

user1169236

I am running one shell script on my App server which will go on another machine where Postgres database is installed. It will execute query and return couple of IDs and store into variables. Please find below my shell script.

ssh root@<Remote_HOST> 'bash -s'<< EOF 
projectid=`/usr/pgsql-9.4/bin/psql $DB_NAME -U $DB_USER -h $DB_HOST -t -c "select projectid from projects where project_Name='$projectName';"`
scenarioid=`/usr/pgsql-9.4/bin/psql $DB_NAME -U $DB_USER -h $DB_HOST -t -c  "select scenarioid from scenarios where scenario='$scenario' and projectid='$projectid';"`
EOF
echo $projectid

If i execute Shell, i get following error : /root/test/data.sh: line 62: /usr/pgsql-9.4/bin/psql: No such file or directory /root/test/data.sh: line 62: /usr/pgsql-9.4/bin/psql: No such file or directory

But on machine where database is installed, if i execute same query, i get proper results. So i am not sure what is wrong, query is fine and directory is present. Even after SSH to remote host, if i do ls or pwd, i am getting proper output. I have already exported database password, so database login without password is already working fine.

Can some please tell me what am i missing here?

user1169236

Finally i was able to resolve my issue by making changes in Shell

projectid=$(ssh root@<Remote_HOST> << EOF 
/usr/pgsql-9.4/bin/psql $DB_NAME -U $DB_USER -h $DB_HOST -t -c "select projectid from projects where project_Name='$projectName';"
EOF)
scenarioid=$(ssh root@<Remote_HOST> << EOF
/usr/pgsql-9.4/bin/psql $DB_NAME -U $DB_USER -h $DB_HOST -t -c "select scenarioid from scenarios where scenario='$scenario' and     projectid='$projectid';"
EOF)
echo "$projectid : $scenarioid"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Facing issue while executing the groovy code in JMeter

From Dev

Facing issue while executing the Groovy code

From Dev

facing issue while populating/referencing the variable in shell

From Dev

Facing strange issue while executing Oracle Stored procedure

From Dev

Facing an issue with executing python package

From Dev

Issue while executing get-acl for remote servers

From Dev

Issue while executing IMPDP command from local server on remote server

From Dev

Facing issue while login redirect

From Dev

Facing warning issue while debugging

From Dev

Facing issue while sending "&" in a string

From Java

While executing NamedNativeQuery Join query after excluding the primary key using postgresql facing error

From Dev

Facing an issue in MERGE SQL query

From Java

Facing javapath error while executing appium script

From Dev

Facing an error while executing the plotly module

From Dev

Facing issue while passing "ip_addr" in url using shell script

From Dev

PostgreSQL encoding issue while executing query from command line

From Java

how to print error in shell script while executing a vertica query?

From Dev

Query performance issue when executing from another database

From Dev

Postgres Query not executing

From Dev

Error while executing SQL query on database: misuse of aggregate: count()

From Dev

shell script executing on remote host

From Dev

Facing urlencoding issue while processing request

From Dev

Facing issue while deserializing the http resposne

From Dev

facing issue while formating the JSON Data

From Dev

Facing issue with MFA while adding account to Yodlee

From Dev

Facing issue while installing ruamel.yaml

From Dev

NodeJs facing the issue while using async waterfall

From Dev

Facing issue while installing Cassandra on MacOs

From Dev

Facing issue while calling @viewchild in angular

Related Related

  1. 1

    Facing issue while executing the groovy code in JMeter

  2. 2

    Facing issue while executing the Groovy code

  3. 3

    facing issue while populating/referencing the variable in shell

  4. 4

    Facing strange issue while executing Oracle Stored procedure

  5. 5

    Facing an issue with executing python package

  6. 6

    Issue while executing get-acl for remote servers

  7. 7

    Issue while executing IMPDP command from local server on remote server

  8. 8

    Facing issue while login redirect

  9. 9

    Facing warning issue while debugging

  10. 10

    Facing issue while sending "&" in a string

  11. 11

    While executing NamedNativeQuery Join query after excluding the primary key using postgresql facing error

  12. 12

    Facing an issue in MERGE SQL query

  13. 13

    Facing javapath error while executing appium script

  14. 14

    Facing an error while executing the plotly module

  15. 15

    Facing issue while passing "ip_addr" in url using shell script

  16. 16

    PostgreSQL encoding issue while executing query from command line

  17. 17

    how to print error in shell script while executing a vertica query?

  18. 18

    Query performance issue when executing from another database

  19. 19

    Postgres Query not executing

  20. 20

    Error while executing SQL query on database: misuse of aggregate: count()

  21. 21

    shell script executing on remote host

  22. 22

    Facing urlencoding issue while processing request

  23. 23

    Facing issue while deserializing the http resposne

  24. 24

    facing issue while formating the JSON Data

  25. 25

    Facing issue with MFA while adding account to Yodlee

  26. 26

    Facing issue while installing ruamel.yaml

  27. 27

    NodeJs facing the issue while using async waterfall

  28. 28

    Facing issue while installing Cassandra on MacOs

  29. 29

    Facing issue while calling @viewchild in angular

HotTag

Archive