score:3
on_error_stop
will not work with the -c
option.
also, the $(...)
surronding the psql
look wrong — do you want to execute the output as a command?
finally, you forgot a backslash after the -l
option
try using a “here document”:
psql \
-x \
$postgres_connection_string \
-w \
-b \
-l ./output.txt \
-a \
-q \
--set on_error_stop=on \
-t <<eof
\copy mytable(...) from '$input_file' csv header
eof
echo "import is done"
Source: stackoverflow.com
Related Query
- psql return value / error killing the shell script that called it?
- Is it possible to return value from ruby script and read that value inside c or shell script?
- A shell script (.sh) that calls an infinite loop called by another script to run in the background
- Taking the return value of a process in shell script
- Write a shell script that will return the list of files skipped by your repository git
- How to escape a value returned from a command that contains special symbol in the shell script
- How to get the return value of a script called with su
- How can I return a value from a c program to the back script that calls it?
- How to set an alias inside a bash shell script so that is it visible from the outside?
- return value from python script to shell script
- Variable in Bash Script that keeps it value from the last time running
- AWK: return value to shell script
- return a value from shell script, into another shell script
- Getting the line number of a shell script error
- Return a single value from a shell script function
- How to stop a bash script when the python script that is called within bash encounters an error?
- How to grep the specific field value from json string using shell script
- Error handling inside a function so that we can exit the script
- Create a shell script that returns the last 5 hash of my commits of my git deposit
- How to return the error from a sourced bash script
- How to use function return value in while test in the bash script
- Return the exit number and value of a Python script in a bash script
- extract the value from the log using shell script
- Viewing the contents of a deleted shell script that is still running
- store nested script return value in shell script
- In a bash script that starts with set -e, can I set the exit code to a different value than the first failed command's?
- How to write a shell script that indents all files C/C++ files in the current directory?
- Shell script - Sorting 'AWS cloudwatch metrics' json array based on the "Timestamp" property value which comes in ISO 8601 UTC format
- Shell script that takes the PID as the input and get the threads associated with each PID and writes it to a file. Can someone help or guide?
- I want a shell script that reads a specific attribute value from an ldapsearch result
More Query from same tag
- Linux lsof Need help parsing output
- How to feed input to an interactive bash script from a text file
- How to create my own bash command options in shell
- For files in directory, only echo filename (no path)
- Print incremental date using while loop in bash
- Updating Statsmodels in Anaconda
- Running parallel commands in bash
- Check if DOS or bash from inside web app
- How to rename all files in a directory from $filename into $Backupfilename
- here document - unexpected end of file
- Extract particular value from column and exit from loop
- How to keep latest 0 in raw digest hash while transfer it through pipe?
- Grep rows from top command based on a condition
- Setting environment variables based on key-value pairs in a file, where some values are quoted expressions
- Recursive call to a duplicated Bash script, making it unable to access the assets
- Using bash to edit text file and display output
- Zshell aliases like !gst inside vim?
- Bash: Inserting one file's content into another file after the pattern
- Replace every occurrence of a word with each line from an list-file
- Bash missing all shell commands
- grep command running in if statement
- Alias CC to Refer to Clang in a Shell?
- Redirect output from program A to program B's input and viceversa
- How to stop Linux aborting PATH search?
- How to pipe files one by one from list into script?
- Bash alias for apt-cache
- Find directories within directories ending in 'l0' that do not contain '*18*' in their names
- Automatically change variables in bash script
- Bash cut pattern
- "libiomp5.so cannot open shared object file" how to slove in Windows 10?