Why do i get syntax error for "[...] 2> >(tee -a $logfile >&2) [...]" in a script in rpm, but not when run from commandline and how to get it work?

TheOneAndOnlyMe

Why do i get a syntax error for "[...] 2> >(tee -a $logfile >&2) [...]" in a script when run as rpm preinstall scriptlet, but not when script runs from commandline?

The purpose of that construct is to allways forward stderr just to the log file, but to have stderr to both, the logfile and the console.

here the complete example script:

#!/bin/bash
LOGFILE=/tmp/example.log;

if mkdir -v /tmp/example 1>>$LOGFILE 2> >(tee -a $LOGFILE >&2);
  then
    echo "ok";
  else
    echo "ko";
    exit 1;
fi

When run as pre scriptlet of a rpm (build with the maven rpm plugin), i get the error message:

syntax error near unexpected token `>'
`         mkdir -v /tmp/example 1>>$LOGFILE 2> >(tee -a $LOGFILE >&2);'

If i invoke the same script from commandline, i get "ok", as expected.

What do i have to do to make it work inside the rpm?

Thank you for helpfull answers.

msuchy

This is not rpm related. If you put it in file script and you try to run this from command line, you will get the same error. This is because of script execute bash as posix compatible. See https://stackoverflow.com/a/12122609/3489429

unset POSIXLY_CORRECT

will work, but you rather should avoid process expansion and use e.g. pipes.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why do I get a syntax error if I run this in the console? {} === {}

From Dev

Why do I get syntax error when converting with UFormat in Powershell

From Dev

Why do I get this error when I run 'bower install'?

From Dev

Why do I get this error when I run 'bower install'?

From Dev

Why do I get syntax error before: '{'?

From Dev

How do I get the onEdit script to run

From Dev

How can I to run php script from powershell-commandline?

From Dev

Why do I get a syntax error when I try to print a nested hash that has keys containing colons?

From Dev

Why do I get a MySQL syntax error (1604) when I select by email address?

From Dev

Why I always get a syntax error in bash script

From Dev

Why do i get this error? "Syntax error on token "implements", @ expected"

From Dev

Why i get error when run the sql server script in c#?

From Dev

Why i get error when run the sql server script in c#?

From Dev

Why do I get "package does not exist" error when I run maven install?

From Dev

Why do I get a "String index out of range" error when I run this program?

From Dev

Why do I get this Error? SyntaxError: invalid syntax

From Dev

Why do I get a syntax error using the ternary operator?

From Dev

Why do I get "syntax error near unexpected token `(' "?

From Dev

Why do I get "Syntax error in INSERT INTO statement"?

From Dev

why do I get syntax error of not a group by expression in below query?

From Dev

Why I get a syntax error when using typedef in verilog?

From Dev

Why do I get a train when I run 'ls'?

From Dev

Why do I get run-time error '2759' when saving the record? access 2010

From Dev

Haskell: Why I can load this file in ghci but when I try to do the same in hugs I get a syntax error?

From Dev

Why do I get an error when double quoting single quotes in a script that launches a remote SSH command?

From Dev

Why do I get access violation run-time error?

From Dev

How do I get the output of a cron script run from my home directory?

From Dev

why do I get an error when i try remove public dir from laravel with htacces

From Dev

Why do I get an authorization error from Docker when I'm trying to pull a public image?

Related Related

  1. 1

    Why do I get a syntax error if I run this in the console? {} === {}

  2. 2

    Why do I get syntax error when converting with UFormat in Powershell

  3. 3

    Why do I get this error when I run 'bower install'?

  4. 4

    Why do I get this error when I run 'bower install'?

  5. 5

    Why do I get syntax error before: '{'?

  6. 6

    How do I get the onEdit script to run

  7. 7

    How can I to run php script from powershell-commandline?

  8. 8

    Why do I get a syntax error when I try to print a nested hash that has keys containing colons?

  9. 9

    Why do I get a MySQL syntax error (1604) when I select by email address?

  10. 10

    Why I always get a syntax error in bash script

  11. 11

    Why do i get this error? "Syntax error on token "implements", @ expected"

  12. 12

    Why i get error when run the sql server script in c#?

  13. 13

    Why i get error when run the sql server script in c#?

  14. 14

    Why do I get "package does not exist" error when I run maven install?

  15. 15

    Why do I get a "String index out of range" error when I run this program?

  16. 16

    Why do I get this Error? SyntaxError: invalid syntax

  17. 17

    Why do I get a syntax error using the ternary operator?

  18. 18

    Why do I get "syntax error near unexpected token `(' "?

  19. 19

    Why do I get "Syntax error in INSERT INTO statement"?

  20. 20

    why do I get syntax error of not a group by expression in below query?

  21. 21

    Why I get a syntax error when using typedef in verilog?

  22. 22

    Why do I get a train when I run 'ls'?

  23. 23

    Why do I get run-time error '2759' when saving the record? access 2010

  24. 24

    Haskell: Why I can load this file in ghci but when I try to do the same in hugs I get a syntax error?

  25. 25

    Why do I get an error when double quoting single quotes in a script that launches a remote SSH command?

  26. 26

    Why do I get access violation run-time error?

  27. 27

    How do I get the output of a cron script run from my home directory?

  28. 28

    why do I get an error when i try remove public dir from laravel with htacces

  29. 29

    Why do I get an authorization error from Docker when I'm trying to pull a public image?

HotTag

Archive