D
D
Dmitry2017-01-08 19:20:05
linux
Dmitry, 2017-01-08 19:20:05

How to redirect the output of a command to a file?

screen -d -m -S session ping 192.168.1.1 -c 10 >~/file &
This doesn't work.
Although if you just ping 192.168.1.1 -c 10 >~/file & then the redirection works.
I tried to crutch like this
screen -d -m -S session ~/run.sh
the script itself run.sh
#!/bin/bash
$1 >~/buffer
and, accordingly, if called from the console as
./run.sh '192.168.1.1 - c 10' it works as it should
, but if you call the command from screen in general, then
screen -d -m -S session ~/run.sh '192.168.1.1 -c 10' does not work again,
since the parameter that I pass to run.sh not getting through.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
ky0, 2017-01-08
@ky0

Quotes?

S
Saboteur, 2017-01-08
@saboteur_kiev

Just :
screen bash -c "ping 192.168.1.1 -c 10 > file.txt"

M
malbaron, 2017-01-08
@malbaron

Stream redirection do
filename 2>&1

D
Dmitry, 2017-01-08
@Sad_Bro

guys, thanks to everyone for participating, in the furnace of screen, now I tried to do the same through tmux, and everything worked out!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question