Advertisement
j0h

bashMp3Embed.sh

j0h
May 10th, 2023 (edited)
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #!/bin/bash
  2. #script to embed an mp3 into a shell script.
  3. #Usage:
  4. #cat thisScript.sh mp3FileName.mp3 > play.sh
  5. #bash play.sh
  6.  
  7. ARCHIVE=`awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' $0`
  8.  
  9. #redirect embedded archive to a file.
  10. #specificly, read the script,  get the number of lines before ARCHIVE_BELOW, and redirect after that to a file
  11. tail -n+$ARCHIVE $0 > file.mp3
  12.  
  13. #play the file once and exit
  14. cvlc --play-and-exit --ignore-config file.mp3
  15. rm file.mp3
  16.  
  17. exit 0
  18.  
  19. __ARCHIVE_BELOW__
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement