1

create a server on port 790. This should be a listening port in continuous mode which runs something which tell you how many files can be found in /root. When you are counting you should ignore hidden files. Here is I have done

  1. I have created file at /root/script1 file which consists of the counts of the files in root
  2. Created 'scr.sh'

    #!/bin/bash ls | wc -l > /root/counts

  3. creating the server netcat -l 127.0.0.1 -p 790 -e 'cat /root/script1' --continuous

  4. connecting with the server netcat 127.0.0.1 790

How do I call scr.sh file while connecting with the server so that after every successful connection the script1 file updated which holds the count of the files at /root directory?

  • Call your scr.sh script instead of 'cat /root/script1'. Have you scr.sh output ls | wc -l – Red Cricket Dec 4 '16 at 20:25
  • @RedCricket should I echo 'ls | wc -l' in scr.sh? – Amjad Dec 4 '16 at 20:37
  • yes. that's what I meant ;) – Red Cricket Dec 4 '16 at 20:38
  • I have done like result = $(ls | wc -l) and then echo "$result" but getting no output – Amjad Dec 4 '16 at 21:05
  • This is a question posed on the Kali tutorial linuxzoo.net/page/kali_wk1c.html – steve Dec 4 '16 at 22:29

Your Answer

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

Browse other questions tagged or ask your own question.