Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i7Kkl-0002iY-Gg for pgsql-general@arkaria.postgresql.org; Mon, 09 Sep 2019 14:34:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i7Kkk-00033e-8b for pgsql-general@arkaria.postgresql.org; Mon, 09 Sep 2019 14:34:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i7Kki-0002oP-Ug for pgsql-general@lists.postgresql.org; Mon, 09 Sep 2019 14:34:49 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i7Kkg-0002Ul-78 for pgsql-general@lists.postgresql.org; Mon, 09 Sep 2019 14:34:47 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 491AB21F15; Mon, 9 Sep 2019 10:34:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 09 Sep 2019 10:34:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=y U/y37njVygC282KE8oV/dkxEE+8fe+rqC10HbaNHRU=; b=dKT0MsBmKH4YYSlCW zfOpk70ykwGGYGLCg9Q9qmaLRCZeHomrCYWm0U3gMlAGGpko9J6v88iFqV9ybkX0 Q4OoG2FqSE5+CFeKXvdlJLRzjJEhpw+/FTseyL4nMJYMJcRbMoyo4KEZqfd4ECl+ RdSLjrOptUpmhCl1bRKr2aeyfihy/EaXDQBU03WMhYZA9J0RxFDNLbVVzvaH4Fih xXpaG0QJGfMsnXw2krAbhhrdobMiLPLeJouLYFbEw857izirzVzF3Opvwb/FKZ7G seq21ryYJexPw4MK3vxW8rVCO073PuhcpYnNroec43fXc+SZBDSzcK0kIIM3yYu3 c5MQQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=yU/y37njVygC282KE8oV/dkxEE+8fe+rqC10HbaNH RU=; b=tgVXod8y7zpMEQAI4Rf9Diw3D4fqfaPdGqTKUM5XREmMQAz1GlpgwvoFS +yOcQMy2F9qH75jYMeTF8eA7fBMHVPhVrAorB2jcXjVzfo1UwtOAqYFdLfvReA/j 1FUs3ZUit/Mcj6js+Xvs74ZLG0eOg/BQoCA4SCna0fbKV/i8H38Q6Z9jYu8gmMEd KHt1lEncixI7FZHpowq5aGZeKeL/6HD92ntxOo6z5EAlq8OWDUQvBQujm/VIYUfY gOf9zZQN55E2f16YoTWWKN5Z4CwLCCxnvX3p2fSpHdIDy1a+NYYrZckAz3iqXnpt ONetM51DHgLUT1wICgt42jixlaHXA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudekiedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepudejgedrvddurdejiedrvdegnecurfgrrhgrmhepmhgrihhlfhhrohhm pegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsthgvrh fuihiivgeptd X-ME-Proxy: Received: from [192.168.1.3] (174-21-76-24.tukw.qwest.net [174.21.76.24]) by mail.messagingengine.com (Postfix) with ESMTPA id 0D9DED6005B; Mon, 9 Sep 2019 10:34:43 -0400 (EDT) Subject: Re: database "cdf_100_1313" does not exist To: nikhil raj , Tom Lane Cc: Rob Sargent , Dan Livingston , Karsten Hilbert , pgsql-general@lists.postgresql.org References: <20190909115454.GC2813@hermes.hilbert.loc> <45AD213B-B975-4A43-9C02-3C1513CF23F5@gmail.com> <28857.1568038643@sss.pgh.pa.us> From: Adrian Klaver Message-ID: <0c3c64fa-d80b-e4ec-787d-aed2a66f22e2@aklaver.com> Date: Mon, 9 Sep 2019 07:34:43 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/9/19 7:30 AM, nikhil raj wrote: > Hi All, > > just did few modification of the shell command still having the same > issue. Having the issue with the Grant command only its not taking the > parameters. > >  /usr/lib/postgresql/11/bin/psql -p 5432 -U postgres -d $DBLIST -c > "GRANT CONNECT ON DATABASE \"$DBLIST\" TO cpupdate" > ERROR:  database " CDF_100_1313" does not exist You are not showing how you are currently generating DBLIST. From the looks of it you have a leading space in the database name: " CDF_100_1313" > * > * > *** For the above one we have its taking space in the Databases name > starting.* > > /usr/lib/postgresql/11/bin/psql -p 5432 -U postgres -d $DBLIST -c "GRANT > CONNECT ON DATABASE "$DBLIST" TO cpupdate" > psql: warning: extra command-line argument "ASD_100_1313 TO cpupdate" > ignored > ERROR:  syntax error at end of input > LINE 1: GRANT CONNECT ON DATABASE >                                   ^ > > > > On Mon, Sep 9, 2019 at 7:47 PM Tom Lane > wrote: > > > On Sep 9, 2019, at 7:16 AM, nikhil raj > wrote: > >> /usr/lib/postgresql/11/bin/psql -p 5432 -U postgres -d $DBLIST > -c "GRANT CONNECT ON DATABASE $DBLIST TO cpupdate" > >> ERROR:  database "cdf_100_1313" does not exist > > This still isn't quoted properly.  It's tricky since double-quote is > special to both the shell and SQL.  You need something like > > /usr/lib/postgresql/11/bin/psql -p 5432 -U postgres -d "$DBLIST" -c > "GRANT CONNECT ON DATABASE \"$DBLIST\" TO cpupdate" > >                         regards, tom lane > -- Adrian Klaver adrian.klaver@aklaver.com