Output "hostname" on linux to a file command

Not sure what I am doing wrong but I am as I can run this command locally on RHEL 6 works fine. But this just creates the output file with no content and shows completed. I am open to other methods as well as this was one that I tried.

// Enter your action script here
if {name of operating system contains “inux”}
delete "/opt/BESClient/bin/CIPcombinedaccounts.csv"
wait sh -c " hostname >>/opt/BESClient/bin/CIPcombinedaccounts.csv"
endif

You shouldn’t need to put your command in quotes. You also don’t need to invoke a shell to run it.

// Enter your action script here
if {name of operating system contains "inux"}
delete "/opt/BESClient/bin/CIPcombinedaccounts.csv"
wait hostname >> /opt/BESClient/bin/CIPcombinedaccounts.csv
endif

that changed the hostname to >> on the system

that was weird as it did change the hostname to >> . I am not sure why that happened excepted it saw the >> as a new hostname which is written temporary.

it’s because of how the “hostname” command works. If you just want to get the hostname by itself inside the file, it may be easier to just create the file using relevance.

createfile until "THISISTHENEND"
{computer name}
THISISTHEEND
move __createfile /opt/BESClient/bin/CIPcombinedaccounts.csv

That was exactly what was needed. Success. Thanks jmaple

1 Like