Need complete output into variable in bash [duplicate]

Clash Royale CLAN TAG#URR8PPP
This question already has an answer here:
How can I preserve new lines coming from a command's output during variable assignment?
1 answer
Why does my shell script choke on whitespace or other special characters?
4 answers
Why is printf better than echo?
4 answers
Following is the command which is in shell script.
var="$(sshpass -p 'password' ssh -o "StrictHostKeyChecking=no" username@hostip <<-EOF
command to run on remote host
EOF
)"
when i echo $var, output is displayed without spaces and new line i.e, trimming spaces and new lines.
i need complete output from the remote host with spaces and new line.
On Running Manually through CLI, getting correct output i.e, with spaces and line. But on echoing the varibale($var) output getting trimmed.
tried this echo $var, still no luck, getting output trimmed of white spaces and new line.
bash shell ssh echo sshpass
marked as duplicate by steeldriver, Rui F Ribeiro, roaima, Romeo Ninov, Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jan 29 at 19:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How can I preserve new lines coming from a command's output during variable assignment?
1 answer
Why does my shell script choke on whitespace or other special characters?
4 answers
Why is printf better than echo?
4 answers
Following is the command which is in shell script.
var="$(sshpass -p 'password' ssh -o "StrictHostKeyChecking=no" username@hostip <<-EOF
command to run on remote host
EOF
)"
when i echo $var, output is displayed without spaces and new line i.e, trimming spaces and new lines.
i need complete output from the remote host with spaces and new line.
On Running Manually through CLI, getting correct output i.e, with spaces and line. But on echoing the varibale($var) output getting trimmed.
tried this echo $var, still no luck, getting output trimmed of white spaces and new line.
bash shell ssh echo sshpass
marked as duplicate by steeldriver, Rui F Ribeiro, roaima, Romeo Ninov, Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jan 29 at 19:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How can I preserve new lines coming from a command's output during variable assignment?
1 answer
Why does my shell script choke on whitespace or other special characters?
4 answers
Why is printf better than echo?
4 answers
Following is the command which is in shell script.
var="$(sshpass -p 'password' ssh -o "StrictHostKeyChecking=no" username@hostip <<-EOF
command to run on remote host
EOF
)"
when i echo $var, output is displayed without spaces and new line i.e, trimming spaces and new lines.
i need complete output from the remote host with spaces and new line.
On Running Manually through CLI, getting correct output i.e, with spaces and line. But on echoing the varibale($var) output getting trimmed.
tried this echo $var, still no luck, getting output trimmed of white spaces and new line.
bash shell ssh echo sshpass
This question already has an answer here:
How can I preserve new lines coming from a command's output during variable assignment?
1 answer
Why does my shell script choke on whitespace or other special characters?
4 answers
Why is printf better than echo?
4 answers
Following is the command which is in shell script.
var="$(sshpass -p 'password' ssh -o "StrictHostKeyChecking=no" username@hostip <<-EOF
command to run on remote host
EOF
)"
when i echo $var, output is displayed without spaces and new line i.e, trimming spaces and new lines.
i need complete output from the remote host with spaces and new line.
On Running Manually through CLI, getting correct output i.e, with spaces and line. But on echoing the varibale($var) output getting trimmed.
tried this echo $var, still no luck, getting output trimmed of white spaces and new line.
This question already has an answer here:
How can I preserve new lines coming from a command's output during variable assignment?
1 answer
Why does my shell script choke on whitespace or other special characters?
4 answers
Why is printf better than echo?
4 answers
bash shell ssh echo sshpass
bash shell ssh echo sshpass
edited Jan 29 at 19:03
msp9011
4,36944066
4,36944066
asked Jan 29 at 18:43
sachin_ghagaresachin_ghagare
32
32
marked as duplicate by steeldriver, Rui F Ribeiro, roaima, Romeo Ninov, Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jan 29 at 19:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by steeldriver, Rui F Ribeiro, roaima, Romeo Ninov, Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jan 29 at 19:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes