Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 0.58 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. troubles while redirecting stderr in csh
  2. my $out = `cmd`
  3.        
  4. my $out = `sh -c "cmd 2>&1"`
  5.        
  6. tcsh$ cmd >& logfile.log
  7.        
  8. #!/bin/sh
  9.  
  10. echo stdout
  11. echo STDERR 1>&2
  12.        
  13. echo tty > /dev/tty
  14.        
  15. my $out = `sh -c "cmd 2>&1"`;
  16.        
  17. my $out = `cmd 2>&1`;
  18.        
  19. % perl -le '$out = `sh -c "grep missing /dev/nowhere 2>&1" | cat -n`; chomp $out; print "got <<<$out>>>"'
  20. got <<<     1   grep: /dev/nowhere: No such file or directory>>>
  21.        
  22. % perl -le '$out = `grep missing /dev/nowhere 2>&1 | cat -n`; chomp $out; print "got <<<$out>>>"'
  23. got <<<     1   grep: /dev/nowhere: No such file or directory>>>