ssh in for loop and excute command as su

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












kamal@shell001:~ $ for i in `cat FILE`;do ssh $i -l localadmin 'su;ipmitool bmc reset cold';done
localadmin@server1's password:
Unknown command: su;ipmitool


Can someone please suggest how to execute ssh and switch to su and run any command. Thanks you



I am using Debian 4.1.35-1 (debian-kernel@lists.debian.org).



sudo doesn't work.



server1# su;ipmitool mc info 
Unknown command: su;ipmitool

server1# su|ipmitool mc info
Unknown command: su|ipmitool

server1# su
root@server11:~#


Command after su with semicolon is not working. After switching as root, the command works.







share|improve this question





















  • 1) Please format your question and 2) did you try whereis su? and also man su as you are not using it properly, but at the same time it is difficult to understand what you want to do. Are you mixing su with sudo maybe?
    – Patrick Mevzek
    May 8 at 23:15










  • Add relevant information into the text of your question that you can edit, not as comments.
    – Patrick Mevzek
    May 8 at 23:20














up vote
0
down vote

favorite












kamal@shell001:~ $ for i in `cat FILE`;do ssh $i -l localadmin 'su;ipmitool bmc reset cold';done
localadmin@server1's password:
Unknown command: su;ipmitool


Can someone please suggest how to execute ssh and switch to su and run any command. Thanks you



I am using Debian 4.1.35-1 (debian-kernel@lists.debian.org).



sudo doesn't work.



server1# su;ipmitool mc info 
Unknown command: su;ipmitool

server1# su|ipmitool mc info
Unknown command: su|ipmitool

server1# su
root@server11:~#


Command after su with semicolon is not working. After switching as root, the command works.







share|improve this question





















  • 1) Please format your question and 2) did you try whereis su? and also man su as you are not using it properly, but at the same time it is difficult to understand what you want to do. Are you mixing su with sudo maybe?
    – Patrick Mevzek
    May 8 at 23:15










  • Add relevant information into the text of your question that you can edit, not as comments.
    – Patrick Mevzek
    May 8 at 23:20












up vote
0
down vote

favorite









up vote
0
down vote

favorite











kamal@shell001:~ $ for i in `cat FILE`;do ssh $i -l localadmin 'su;ipmitool bmc reset cold';done
localadmin@server1's password:
Unknown command: su;ipmitool


Can someone please suggest how to execute ssh and switch to su and run any command. Thanks you



I am using Debian 4.1.35-1 (debian-kernel@lists.debian.org).



sudo doesn't work.



server1# su;ipmitool mc info 
Unknown command: su;ipmitool

server1# su|ipmitool mc info
Unknown command: su|ipmitool

server1# su
root@server11:~#


Command after su with semicolon is not working. After switching as root, the command works.







share|improve this question













kamal@shell001:~ $ for i in `cat FILE`;do ssh $i -l localadmin 'su;ipmitool bmc reset cold';done
localadmin@server1's password:
Unknown command: su;ipmitool


Can someone please suggest how to execute ssh and switch to su and run any command. Thanks you



I am using Debian 4.1.35-1 (debian-kernel@lists.debian.org).



sudo doesn't work.



server1# su;ipmitool mc info 
Unknown command: su;ipmitool

server1# su|ipmitool mc info
Unknown command: su|ipmitool

server1# su
root@server11:~#


Command after su with semicolon is not working. After switching as root, the command works.









share|improve this question












share|improve this question




share|improve this question








edited May 9 at 7:28









GAD3R

22.1k154891




22.1k154891









asked May 8 at 23:05









Kamal Sahoo

32




32











  • 1) Please format your question and 2) did you try whereis su? and also man su as you are not using it properly, but at the same time it is difficult to understand what you want to do. Are you mixing su with sudo maybe?
    – Patrick Mevzek
    May 8 at 23:15










  • Add relevant information into the text of your question that you can edit, not as comments.
    – Patrick Mevzek
    May 8 at 23:20
















  • 1) Please format your question and 2) did you try whereis su? and also man su as you are not using it properly, but at the same time it is difficult to understand what you want to do. Are you mixing su with sudo maybe?
    – Patrick Mevzek
    May 8 at 23:15










  • Add relevant information into the text of your question that you can edit, not as comments.
    – Patrick Mevzek
    May 8 at 23:20















1) Please format your question and 2) did you try whereis su? and also man su as you are not using it properly, but at the same time it is difficult to understand what you want to do. Are you mixing su with sudo maybe?
– Patrick Mevzek
May 8 at 23:15




1) Please format your question and 2) did you try whereis su? and also man su as you are not using it properly, but at the same time it is difficult to understand what you want to do. Are you mixing su with sudo maybe?
– Patrick Mevzek
May 8 at 23:15












Add relevant information into the text of your question that you can edit, not as comments.
– Patrick Mevzek
May 8 at 23:20




Add relevant information into the text of your question that you can edit, not as comments.
– Patrick Mevzek
May 8 at 23:20










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Shell operators only work in a shell.



ssh ... sh -c '...;...'





share|improve this answer





















  • for i in cat FILE;do ssh localadmin@$i "su -c 'ipmitool bmc reset cold'";done Thank you it's working.
    – Kamal Sahoo
    May 8 at 23:49










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442649%2fssh-in-for-loop-and-excute-command-as-su%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










Shell operators only work in a shell.



ssh ... sh -c '...;...'





share|improve this answer





















  • for i in cat FILE;do ssh localadmin@$i "su -c 'ipmitool bmc reset cold'";done Thank you it's working.
    – Kamal Sahoo
    May 8 at 23:49














up vote
1
down vote



accepted










Shell operators only work in a shell.



ssh ... sh -c '...;...'





share|improve this answer





















  • for i in cat FILE;do ssh localadmin@$i "su -c 'ipmitool bmc reset cold'";done Thank you it's working.
    – Kamal Sahoo
    May 8 at 23:49












up vote
1
down vote



accepted







up vote
1
down vote



accepted






Shell operators only work in a shell.



ssh ... sh -c '...;...'





share|improve this answer













Shell operators only work in a shell.



ssh ... sh -c '...;...'






share|improve this answer













share|improve this answer



share|improve this answer











answered May 8 at 23:17









Ignacio Vazquez-Abrams

32k66780




32k66780











  • for i in cat FILE;do ssh localadmin@$i "su -c 'ipmitool bmc reset cold'";done Thank you it's working.
    – Kamal Sahoo
    May 8 at 23:49
















  • for i in cat FILE;do ssh localadmin@$i "su -c 'ipmitool bmc reset cold'";done Thank you it's working.
    – Kamal Sahoo
    May 8 at 23:49















for i in cat FILE;do ssh localadmin@$i "su -c 'ipmitool bmc reset cold'";done Thank you it's working.
– Kamal Sahoo
May 8 at 23:49




for i in cat FILE;do ssh localadmin@$i "su -c 'ipmitool bmc reset cold'";done Thank you it's working.
– Kamal Sahoo
May 8 at 23:49












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442649%2fssh-in-for-loop-and-excute-command-as-su%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay