PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Sending & Receiving Binary Files Via Bash On Linux

Go down

Sending & Receiving Binary Files Via Bash On Linux Empty Sending & Receiving Binary Files Via Bash On Linux

Post by jamied_uk 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!"
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Sending & Receiving Binary Files Via Bash On Linux Empty Re: Sending & Receiving Binary Files Via Bash On Linux

Post by jamied_uk 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!"
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Sending & Receiving Binary Files Via Bash On Linux Empty Re: Sending & Receiving Binary Files Via Bash On Linux

Post by jamied_uk 22nd July 2016, 16:43

Check Out Sending Messages Via Netcat & Bash Link

jnet.forumotion.com/t1326-messeging-with-netcat-script-with-bash-on-linux#1848
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Sending & Receiving Binary Files Via Bash On Linux Empty Re: Sending & Receiving Binary Files Via Bash On Linux

Post by jamied_uk 26th May 2018, 12:51

2018 Edition now includes more file types and improved code



J~Net 2018
File Sending Kit For Linux Bash Using Netcat



Box Update Link

app.box.com/s/1zs6gtgs2zbt4rpjem8vesq1i3kxigo2


Forum Link

https://jnet.forumotion.com/t1325-sending-receiving-binary-files-via-bash-on-linux?highlight=sending+file+with+netcat
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Sending & Receiving Binary Files Via Bash On Linux Empty Re: Sending & Receiving Binary Files Via Bash On Linux

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

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