0

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?

1 Answer 1

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .