Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: processing PSQL with system command

by g_speran (Scribe)
on Mar 30, 2022 at 14:17 UTC ( [id://11142545]=note: print w/replies, xml ) Need Help??


in reply to Re: processing PSQL with system command
in thread processing PSQL with system command

I've tried that as well and fails
Disabling ConnectEMC & Email Home PSQL: psql -p 5555 mcdb -c "update ev_cus_prof set active='f' where ep +id='INIT_EV_HIGH_PRIORITY';" ERROR: column "init_ev_high_priority" does not exist LINE 1: update ev_cus_prof set active=f where epid=INIT_EV_HIGH_PRIO.. +.

On this system we are not permitted to install any modules, so I need to try to make it work with all native modules/commands

Replies are listed 'Best First'.
Re^3: processing PSQL with system command
by NetWallah (Canon) on Mar 31, 2022 at 05:01 UTC
    On this system we are not permitted to install any modules
    There are multiple indications that your system is an Avamar AVE.

    The standard Avamar installation has included the perl DBI and DBD::Pg modules pre-installed for at least 15 years.
    No additional module installation required.

    Ask your Avamar support representative to obtain "profileadmin.pl" from the Avamar FTP site.(I am the humble author)
    That perl script will likely fulfill your Avamar profile editing needs and a lot more.

                    "These opinions are my own, though for a small fee they be yours too."

Re^3: processing PSQL with system command
by hippo (Bishop) on Mar 30, 2022 at 14:34 UTC
    On this system we are not permitted to install any modules

    Well then you will be stuck in quote-escaping hell as I see now you have a nasty mix of both double and single quotes there. This test looks OK:

    use strict; use warnings; use Test::More tests => 1; my $want = q{su - admin -c "psql -p 5555 mcdb -c \\"update ev_cus_prof + set active='f' where epid='INIT_EV_HIGH_PRIORITY';\\""}; my $PSQL = q{psql -p 5555 mcdb -c \"update ev_cus_prof set active='f' +where epid='INIT_EV_HIGH_PRIORITY';\"}; my $cmd = qq{su - admin -c "$PSQL"}; is $cmd, $want, "have $want";

    But, in your shoes I would approach whichever entity has imposed the no-modules rule and point out that it means you have to ask the help of complete strangers on the internet to solve what would otherwise be a trivial task.


    🦛

      Thank you Kindly!!!

      The following worked
      my $PSQL = q{psql -p 5555 mcdb -c \"update ev_cus_prof set act +ive='f' where epid='INIT_EV_HIGH_PRIORITY';\"}; system(qq{su - admin -c "$PSQL"});
Re^3: processing PSQL with system command
by Fletch (Bishop) on Mar 30, 2022 at 14:52 UTC

    Maybe slightly long in the tooth, but Yes, even you can use CPAN

    Edit: That being said, if you're dead set on taking the hard route you'd be better served writing the SQL into a file and then telling psql to run that SQL script instead of trying using -c and outguessing how n layers of arbitrary quoting are going to be pulled (or not pulled) apart by however many levels of interpreting.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re^3: processing PSQL with system command
by cavac (Parson) on Mar 31, 2022 at 12:23 UTC

    On this system we are not permitted to install any modules

    I have seen that policy countless times. It's usually "for security reasons". My usual answer to the "admin" is along the lines in writing: "This is a new security problem created by your policy. These workarounds you are proposing are very insecure! Are you really sure you want it implemented this way? Are you taking the responsibility for it?"

    Just make sure you CC a number of relevant people (like: your boss, the admin's boss, etc). So when the fit hits the shan, too many high level tie wearers are involved to make this a big affair that gets blamed solely on you. It usually gets swept under the rug, along with the results of all the other "informed decisions" made by middle management over the past year.

    perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'
Re^3: processing PSQL with system command
by Anonymous Monk on Mar 30, 2022 at 18:12 UTC
    On this system we are not permitted to install any modules, so I need to try to make it work with all native modules/commands

    I can see your future and it holds sql injection attacks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11142545]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 04:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found