The tag has no wiki summary.

learn more… | top users | synonyms

3
votes
1answer
103 views

What are the bash shell length limitations for here-docs?

What are the length limitations for using here-docs as part of bash command lines? I am finding that short here-docs work fine, but when they get longer there is some point or structure after which ...
3
votes
3answers
125 views

Can you source a “here document”?

Let's say I have a bash script that acts as a config file for another bash script: config.sh: verbose=yes echo "Malicious code!" name=test script.sh: source config.sh echo "After sourcing: ...
1
vote
1answer
217 views

What does this `cat` statement do?

I'm new to Linux and trying to figure out what this statement in a Bash file does. I think it combines stdout, stderr and output it to the file $log is pointing to and append the multiline string to ...
1
vote
2answers
44 views

awk - read program AND input from the standard input?

Is it possible for awk to read the program and the input from the standard input? I would like to be able to pipe a file to the following function. process_data () { awk -f - <<EOF {print} ...
5
votes
1answer
66 views

Is it possible to use multiple here-docs in bash?

Can one use multiple here-docs to provide input to a command in bash? $ cat <<<foo <<<bar bar $ cat <<EOF1 <<EOF2 > foo > EOF1 > bar > EOF2 bar Obviously, ...
0
votes
2answers
75 views

Why does passing a HEREDOC as a string to `ruby -e` not work?

For reasons I don't understand, it seems to be impossible to pass a heredoc as an expression to a Ruby interpreter: $ ruby -e <<END heredoc> puts 'hi' heredoc> END ruby: no code ...
0
votes
2answers
333 views

Passing a variable to a bash script that uses 'EOF' and considers the variable a literal [closed]

in this script i end up with "$1" being saved to the /test file. #!/bin/bash cat > /test << 'EOF' $1 EOF the truth is.. i need to keep 'EOF' as 'EOF' because my argument($1) contains ...
2
votes
2answers
141 views

“cat” command: how to automatically escape everything that might be a violation?

If you copy the contents of httpd.conf and then paste it into a cat command.. such as this one.. #!/bin/bash cat > /test << EOF pasted here.. EOF you run into this error: -bash: ...
1
vote
0answers
25 views

How to combine Bash's read with HERE-document when shopt -os errexit is in place? [duplicate]

I am trying to make use of the solution presented in one of the answers of http://stackoverflow.com/questions/1167746/how-to-assign-a-heredoc-value-to-a-variable-in-bash In Bash version ...
7
votes
2answers
149 views

How to combine Bash's process substitution with HERE-document?

In Bash version 4.2.47(1)-release when I try to catenate formatted text that comes from a HERE-dcoument like so: cat <(fmt --width=10 <<FOOBAR (I want the surrounding parentheses to be part ...
1
vote
1answer
37 views

Using cat to modify ~/.bash_profile seems to remove __git_ps1 compeltely

I want my prompt to display the current git-branch when inside of a repo directory. e.g., [desktop repo(master)]$ In my terminal I can type: cat <<EOF >> ~/.bash_profile ...
3
votes
6answers
1k views

Remove last comma from a bash for loop generated string

I am dealing with a situation where I need to create a comma separated list from an array into a heredoc and remove the last comma. I am using bash for piped into sed which is erasing all commas ...
-4
votes
1answer
640 views

Shell script- syntax error: unexpected end of file [closed]

I'm practicing some scripts from a book and I keep getting an unexpected end-of-file syntax error. The images below show the error message and the script that uses basic commands to create a ...
1
vote
2answers
250 views

Auto answering password for OPENSSL using HEREDOC [closed]

I have the following command but it doesn't work for me... cd /etc/postfix/ssl/ && openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024 <<PASS password password PASS The output ...
2
votes
3answers
5k views

How to login as root from Bash and do stuff

This is my simple bash: cat test.sh #!/bin/bash echo "hello" su - root -c /path/to/script.sh <<EOF password EOF whoami echo "good bye" But I get this error: ...
2
votes
1answer
78 views

< and << in UNIX /Linux

What is the option <<and < are used in linux for??? For example cat << abc.txt I know its a stupid question, but i was not able to search it on google as i did not know what ...
1
vote
1answer
138 views

Cat write text with “$” inside

I want to write configuration information to a specific file which has dollar signs ($) inside. That seems to be a problem. Here's what I did: $ cat >> /etc/nginx/nginx.conf <<EOF # For ...
1
vote
1answer
208 views

Execute command on remote host fails

I'm trying to execute some commands on remote host like this : ssh -t -t -l user 172.20.20.20 <<EOF pid=$(ps -ef | grep [a]pp-management | awk '{print $2}') && kill -9 $pid && ...
10
votes
3answers
258 views

bash: Using read <<<“$VARIABLE” on a read-only root partition

Just by coincidence I had to use my ATA-ID-to-device-name script (found here: http://serverfault.com/questions/244944/linux-ata-errors-translating-to-a-device-name/426561#426561) on a read-only / ...
2
votes
2answers
401 views

setting variables inside subshell when using <<

I am using the following method in order to pass commands into a subshell that is started by "newgrp". #!/bin/csh echo "Before newgrp" /usr/bin/newgrp users <<EONG echo "hello from within ...
5
votes
1answer
2k views

How to echo variables using cat into file?

I have simple script like this: #!/bin/bash BOO=bla-bla-bla cat > ./Makefile <<'EOF' Hello INCLUDES := -I/data/opt/include/ -Ideps/ -I$BOO/include EOF Yet it outputs into ...
7
votes
1answer
1k views

How do you use output redirection in combination with here-documents and cat?

Let's say I have a script that I want to pipe to another command or redirect to a file (piping to sh for the examples). Assume that I'm using bash. I could do it using echo: echo "touch somefile ...
-2
votes
1answer
64 views

Here document and input redirection with -

What does the following command do? In particular I don't understand the role of - in input redirection. cat <<-EOF | command $argument first option second option EOF Is it ...
3
votes
1answer
13k views

Assigning the output of a SQL query to variable

I am connecting to oracle database and firing a query and assigning the output to variable But when I echo the value of the variable it doesn't get printed correctly. count=`sqlplus -s ...
0
votes
1answer
645 views

Use sudo tee with heredoc to append to existing file

From Generate script in bash and save it to location requiring sudo we have this method, which I like: sudo tee "$OUTFILE" > /dev/null <<'EOF' foo bar EOF However, I would like to use that ...
4
votes
3answers
5k views

bash script error stty: standard input: Inappropriate ioctl for device

I'm using here-documents in a bash script to automate installation and setup where a password is required many times. I enter the password once and the script passes it to the various commands. In ...
1
vote
2answers
1k views

using bash script to output new script: need mixture of variables to be replaced and not replaced

I'm having a problem with bash variable substitution. Here's a silly example of what I am trying to do. I need to output a new script from a bash script. A line (see echo in my example) has a mixture ...
0
votes
2answers
304 views

EOF blocks my script?

I have this script (it is actually a snippet from a bigger script). #!/bin/sh if [ $actualsize -ge $MAXSIZE ]; then read dummy FILEPOINT <<EOF `dd if=myfile skip=8001 count=1 bs=1|od -x` ...
8
votes
1answer
2k views

Can't indent heredoc to match nesting's indent

If there's a "First World Problems" for scripting, this would be it. Mainly asking because I feel like I should know how to get around it if I need to. I have the following code in a script I'm ...
1
vote
1answer
441 views

what's wrong with embedding php scripts inside bash ones?

I was trying to use php inside bash script, but I came across several problems. My first try failed with error about bash not being able to find end of here-document. The minimal version that still ...
2
votes
1answer
97 views

Reading multine text inside a bash script

I have following graphviz script which I wish to convert to a bash script. #!/bin/bash graph=$(cat <<GRAPHEND graph match { node[style=filled shape=point label= ""]; ...
2
votes
1answer
1k views

Using a here-doc for `sed` and a file

The title says it all, I want to use a here-doc for sed commands and provide the file to be read and the output file. I've looked at Here-Documents from Advanced Bash Scripting guide but it does not ...
4
votes
1answer
1k views

“unexpected end of file” in bash script

I have this if in a bash script: if [ $ACTION = deploy ]; then ${JAVA_HOME}/bin/java ${JVM_ARGS} weblogic.WLST << EOJ connect('XXX','XXX','t3://XXX:8001') jndi(); ls(); ...