help my friends, windows can normally do this but it won't cut it in this instance, I need a way to run one command with just one parameter being sequencial throughout a few tens of servers for my mate.
I have ssh access to all of them and have the program running on each.
I can make them read the IPs from a file and run one command which is the same usingfor host in $(cat hosts.txt); do ssh "$host" "$command" >"output.$host"; donebut what I need is it to do the certain command with-u d[1-160]on each server going up by one each time. Can anyone think of an easy solution?
For i, host in ... -u $i
>>61822769
Increment a variable in the for loop?
Or what are you asking?
>>61822769
Fuck server scripting in Linux, man. Either install Windows Server or just fucking suck up to the fact that you will never be productive in a Linux environment. I bet you can't even write a script to automate all of this in Bash, whereas Powershell can do all of this in a breeze and is 10x more powerful of a language. OP, some advice for you, just do this shit in a respectable language like C# or Ruby. I dare someone to prove me wrong and show me that Bash is actually not a gimped language.
t. system administrator for an australian private school
>>61822827
1. Ruby doesn't ship with an SSH gem by default
2. OP needs to call a shell command ($command), which means he'll have to call system anyway, thereby making Ruby a pointless layer of abstraction
3. You're a sunbaked drongo
>>61822812
The host part is seperate and Just Werks™.
>>61822820
or create a seperate loop for command to increment it every time i hop to the next server.
>>61822827
sym
>>61822886
Show that you can do what OP wanted in bash without jumping through major hoops and hurdles
>>61822886
that's because bash is a daft language for NEETs
for host in $(cat hosts.txt); do ssh "$host" "$command -u d["{1..160}"]"; done
>>61822959
What about authentication
>>61822959
yeah what >>61822975 said
>>61822975
ssh keys or sshpass
https://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password
>>61822959
>>61823000
Thanks faggot. Always a great helper you guys are.
You can do:ssh -tt "${REMOTEUSER}"@"${REMOTEIP}" "stty raw -echo; ${COMMANDS}"
And build up commands as successive command strings ending in ;, like:COMMANDS=""
COMMANDS+="echo REEEEEEEEEEEEEE ;"
COMMANDS+="echo EAT SHIT REEEEEEEE;"
If it takes multiple lines to get single/double quotes right, then do it.