Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This command gets my ip address:

who am i|cut -d "(" -f2 | cut -d ")" -f1

output:

10.22.184.126

this command sends a ZPL command to 10.22.184.126 on port 5964:

printf '\x5eXA\x7eSD30\x5ePR6\x5ePW544\x5eLL0333\x5eML39,989\x5eJM1280,12\x5eID\x5eJUS\x5eXZ\x5eXA\x5eWD\x5eXZ'|nc 10.22.184.126 5964

but if I replace 10.22.184.126 with who am i|cut -d "(" -f2 | cut -d ")" -f1 like this:

printf '\x5eXA\x7eSD30\x5ePR6\x5ePW544\x5eLL0333\x5eML39,989\x5eJM1280,12\x5eID\x5eJUS\x5eXZ\x5eXA\x5eWD\x5eXZ'|nc who am i|cut -d "(" -f2 | cut -d ")" -f1 5964

then I get:

nc: port range not valid
cut: 5964: No such file or directory

What is the correct syntax to write it on one line?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I think this should make it

$(who am i|cut -d "(" -f2 | cut -d ")" -f1)

printf '\x5eXA\x7eSD30\x5ePR6\x5ePW544\x5eLL0333\x5eML39,989\x5eJM1280,12\x5eID\x5eJUS\x5eXZ\x5eXA\x5eWD\x5eXZ'|nc "$(who am i|cut -d "(" -f2 | cut -d ")" -f1)" 5964
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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