1

I am fresh programmer on shell script. i want to do some automation using nc command via shell scripting. I need to run certain command after connecting server with selected port using nc . server is listening on connected port. we can get prompt to pass content while running from terminal. but i need to pass content many times. So I made a shell file which is containing following code but response is not coming

#!/bin/bash  
#test.sh

function nc_input { echo "ABCD,R,1,5151670,512173140137353,01141456843,0" }

nc_input | nc 10.200.16.223 7913

5
  • If you declare a function on one line, you must put a semi-colon at the end before the closing brace. Commented Jul 6, 2015 at 9:37
  • Where's the server-side code? Commented Jul 6, 2015 at 9:54
  • server is listening on 7913 port. i can pass the content after running nc command from terminal manually. but i want to do automatically through shell script.. Commented Jul 6, 2015 at 10:02
  • Did you add the semicolon mentioned in my first comment? Have you tried changing the first line to #!/bin/bash -xv so you can see what is happening? Is the script running at all? Commented Jul 6, 2015 at 10:11
  • I got some solution from below link. but I could to solve my requirement stackoverflow.com/questions/19265300/… Commented Jul 19, 2015 at 7:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.