bash

Execute a Bash script (Shell Script) from postgres function/procedure/trigger

*爱你&永不变心* 提交于 2021-02-09 08:11:00
问题 CREATE or replace FUNCTION test() RETURNS boolean AS $$ $filename = '/home/postgres'; if (-e $filename) { exec /home/postgres/test.sh & return true; } return false; $$ LANGUAGE plperlu; exec /home/postgres/test.sh & its showing syntax error. Could you please help how to call bash script into postgres funtion/procedure 回答1: Presumably, the code needs to be syntactically valid Perl. So you'll need to clean up a few bits. CREATE or replace FUNCTION test() RETURNS boolean AS $$ my $filename = '

Execute a Bash script (Shell Script) from postgres function/procedure/trigger

送分小仙女□ 提交于 2021-02-09 08:08:13
问题 CREATE or replace FUNCTION test() RETURNS boolean AS $$ $filename = '/home/postgres'; if (-e $filename) { exec /home/postgres/test.sh & return true; } return false; $$ LANGUAGE plperlu; exec /home/postgres/test.sh & its showing syntax error. Could you please help how to call bash script into postgres funtion/procedure 回答1: Presumably, the code needs to be syntactically valid Perl. So you'll need to clean up a few bits. CREATE or replace FUNCTION test() RETURNS boolean AS $$ my $filename = '

Execute a Bash script (Shell Script) from postgres function/procedure/trigger

半腔热情 提交于 2021-02-09 08:06:59
问题 CREATE or replace FUNCTION test() RETURNS boolean AS $$ $filename = '/home/postgres'; if (-e $filename) { exec /home/postgres/test.sh & return true; } return false; $$ LANGUAGE plperlu; exec /home/postgres/test.sh & its showing syntax error. Could you please help how to call bash script into postgres funtion/procedure 回答1: Presumably, the code needs to be syntactically valid Perl. So you'll need to clean up a few bits. CREATE or replace FUNCTION test() RETURNS boolean AS $$ my $filename = '

How do I use the output of an ls command in an if statement in a bash shell [duplicate]

穿精又带淫゛_ 提交于 2021-02-09 07:19:56
问题 This question already has answers here : Test whether a glob has any matches in bash (20 answers) Closed 6 months ago . I want to check if only one instance of a file exists before going on to process that file. I can check how many instances exist using this command: ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l; However, when I go to use this within an if statement, I am warned that the ls: command not found . if [ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l = '1']

How do I use the output of an ls command in an if statement in a bash shell [duplicate]

本小妞迷上赌 提交于 2021-02-09 07:19:01
问题 This question already has answers here : Test whether a glob has any matches in bash (20 answers) Closed 6 months ago . I want to check if only one instance of a file exists before going on to process that file. I can check how many instances exist using this command: ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l; However, when I go to use this within an if statement, I am warned that the ls: command not found . if [ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l = '1']

How do I use the output of an ls command in an if statement in a bash shell [duplicate]

北战南征 提交于 2021-02-09 07:09:43
问题 This question already has answers here : Test whether a glob has any matches in bash (20 answers) Closed 6 months ago . I want to check if only one instance of a file exists before going on to process that file. I can check how many instances exist using this command: ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l; However, when I go to use this within an if statement, I am warned that the ls: command not found . if [ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l = '1']

How do I use the output of an ls command in an if statement in a bash shell [duplicate]

为君一笑 提交于 2021-02-09 07:08:26
问题 This question already has answers here : Test whether a glob has any matches in bash (20 answers) Closed 6 months ago . I want to check if only one instance of a file exists before going on to process that file. I can check how many instances exist using this command: ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l; However, when I go to use this within an if statement, I am warned that the ls: command not found . if [ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l = '1']

why questionmark comes in the end of filename when i create .txt file through shell script? [duplicate]

孤者浪人 提交于 2021-02-09 05:52:09
问题 This question already has answers here : Shell Scripting unwanted '?' character at the end of file name (2 answers) Closed 4 years ago . I am writing one shell script in which I am supposed to create 1 text file. When I do this, a question mark comes at the end of file name. what is the reason? I am trying below methods in bash script. 1) grep ERROR a1* > text.txt 2) touch text.txt In both the methods, instead of text.txt , there is a file generated as text.txt? what should I do to overcome

why questionmark comes in the end of filename when i create .txt file through shell script? [duplicate]

流过昼夜 提交于 2021-02-09 05:52:01
问题 This question already has answers here : Shell Scripting unwanted '?' character at the end of file name (2 answers) Closed 4 years ago . I am writing one shell script in which I am supposed to create 1 text file. When I do this, a question mark comes at the end of file name. what is the reason? I am trying below methods in bash script. 1) grep ERROR a1* > text.txt 2) touch text.txt In both the methods, instead of text.txt , there is a file generated as text.txt? what should I do to overcome

Bash input without pausing the script?

我的未来我决定 提交于 2021-02-09 05:20:22
问题 In Bash the only way to get a (user) input seems to be to use the read method, which pauses the rest of the script. Is there any way to receive a command line input (ending with the enter key) without pausing the script. From what I've seen there may be a way to do it with $1 ..? 回答1: read -t0 can be used to probe for input if your process is structured as a loop #!/bin/bash a='\|/-' spin() { sleep 0.3 a="${a:1}${a:0:1}" echo -n $'\e'7$'\r'"${a:1:1}"$'\e'8 } echo 'try these /|\- , dbpq , |)>)