Sending & Receiving Binary Files Via Bash On Linux

View previous topic View next topic Go down

Sending & Receiving Binary Files Via Bash On Linux

Post by jamied_uk on 22nd July 2016, 14:44

Sending & Receiving Binary Files Via Bash On Linux


There will be 1 video and on the video it is in 2 parts (no markings)

The 1st part is for sending image.gif

the second part is project called anyfile so you can send files other than image.gif (feel free to modify the script)!


There will be 4 sets of code, one for server and 1 for client for each part as explained above

for sending image.gif client

Code:
#!/bin/bash
# (c) J~NET
#  Usage: ./nc_client.sh
clear
echo "Binary Client Reciever"

echo -en "\e[92mPlease Wait \c"
sudo nc -l -p 777 > newimage.gif
count=0
total=34
pstr="[=======================================================================]"

while [ $count -lt $total ]; do
  sleep 0.06 # this is work
  count=$(( $count + 1 ))
  pd=$(( $count * 73 / $total ))
  printf "\r%3d.%1d%% %.${pd}s" $(( $count * 100 / $total )) $(( ($count * 1000 / $total) % 10 )) $pstr
done

echo "All Done!"

Server for above
Code:

#!/bin/bash
# (c) J~NET
# Usage: ./nc_server.sh
clear
echo "Binary Server AKA SENDER"
clear
echo -en "\e[92mPlease Wait \c"
sudo cat image.gif | nc localhost 777
count=0
total=34
pstr="[=======================================================================]"

while [ $count -lt $total ]; do
  sleep 0.06 # this is work
  count=$(( $count + 1 ))
  pd=$(( $count * 73 / $total ))
  printf "\r%3d.%1d%% %.${pd}s" $(( $count * 100 / $total )) $(( ($count * 1000 / $total) % 10 )) $pstr
done
echo "File Sent!"
avatar
jamied_uk
Admin

Posts : 2260
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Sending & Receiving Binary Files Via Bash On Linux

Post by jamied_uk on 22nd July 2016, 14:52

For any file Sending (the client side wont know the extension so resolving that will be be coming soon!



Client side for anyfile sending


Code:
#!/bin/bash
# (c) J~NET
#
clear
echo "Binary Client Reciever"

echo -en "\e[92mPlease Wait \c"
sudo nc -l -p 777 > output
count=0
total=34
pstr="[=======================================================================]"

while [ $count -lt $total ]; do
  sleep 0.06 # this is work
  count=$(( $count + 1 ))
  pd=$(( $count * 73 / $total ))
  printf "\r%3d.%1d%% %.${pd}s" $(( $count * 100 / $total )) $(( ($count * 1000 / $total) % 10 )) $pstr
done

echo "All Done!"


Server


Code:
#!/bin/bash
# (c) J~NET
#
# Usage: ./nc_server.sh "file.ext"
myvar="$@"
clear
echo "Binary Server AKA SENDER"
clear
echo -en "\e[92mPlease Wait \c"
sudo cat $myvar | nc localhost 777
count=0
total=34
pstr="[=======================================================================]"

while [ $count -lt $total ]; do
  sleep 0.06 # this is work
  count=$(( $count + 1 ))
  pd=$(( $count * 73 / $total ))
  printf "\r%3d.%1d%% %.${pd}s" $(( $count * 100 / $total )) $(( ($count * 1000 / $total) % 10 )) $pstr
done
echo "File Sent!"
avatar
jamied_uk
Admin

Posts : 2260
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Sending & Receiving Binary Files Via Bash On Linux

Post by jamied_uk on 22nd July 2016, 16:43

Check Out Sending Messages Via Netcat & Bash Link

jnet.forumn.biz/t1326-messeging-with-netcat-script-with-bash-on-linux#1848
avatar
jamied_uk
Admin

Posts : 2260
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Sending & Receiving Binary Files Via Bash On Linux

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum