question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redirect output to file fails

See original GitHub issue

When executing the following command directly on the cmd line the database is dumped to the file correctly.

When running the same command via .exec. using Grunt.js (see below) the output is in the console and the file is created but has no contents.

shell.exec('mysqldump -u my_user -pmy_pass test > test.sql');

My ultimate goal is to run a dump via ssh like so:

shell.exec("ssh user@host \ mysqldump -u my_user -pmy_pass test > test.sql");

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
c0bracommented, Dec 18, 2014

I found this: #154

shell.exec('command').output.to('path/to/file');

worked for me.

0reactions
nfischercommented, Jul 25, 2016

I’m going to close this issue, since it doesn’t seem like it’s related to ShellJS. Please re-open if the issue persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redirection of stdout to a file not working - Stack Overflow
You have sent stdout to the file, but your program is reporting errors which go to stderr. To setup redirection of stderr, use...
Read more >
Linux Redirect Error Output To File - nixCraft
Linux Redirect Error Output To File ; Syntax To redirect all output to file. The syntax is as follows to redirect output (stdout)...
Read more >
How to redirect stderr to a file [duplicate] - Ask Ubuntu
Redirect stdout to one file and stderr to another file: command > out 2>error · Redirect stdout to a file ( >out ),...
Read more >
Modify 2>&1 so that output goes to a specific file and any ...
Yes, this is possible. The 2>&1 means the following: 2 : stderr > : output redirect & : copy file descriptor 1 :...
Read more >
Redirect output of a program to a file fails - Unix StackExchange
I am attempting to redirect its terminal output to a file using the following command. foo > ./someFile.txt. Now when I run that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found