I have two terminals each running two processes that are supposed to communicate with one another. The way each process is able to communicate is by sending each other the results of uname -n and comparing it to values in a map to determine the type of the process. Since I need the map to be unique I would like my terminals to return different results of uname -n. Is there a way to do this?

  • Run your commands on different hosts when you need uname to display different hostnames
    – HBruijn
    May 14 '18 at 16:02
  • does different host necessarily mean differed computers? May 14 '18 at 16:13
  • 1
    uname -n prints the name of the machine it's running on. So it is probably not what you should be using in your program. May 14 '18 at 17:41

Why not in terminal two create a shell function for uname ?

joes-MacBook-Pro:~ joe$ uname() 
> { 
>   echo "differentHostName" 
> }
joes-MacBook-Pro:~ joe$ uname - n 

Or you could create an alias

joes-MacBook-Pro:~ joe$ alias uname="echo differentHostname" 
joes-MacBook-Pro:~ joe$ uname

Cheers, -Joe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.