The little things give you away... A collection of various small helper stuff
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

33 lignes
886 B

  1. #!/bin/bash
  2. # Usage: wpull2-url-origin [FILENAME] URL
  3. # FILENAME defaults to wpull.db
  4. # Trace back where a URL was discovered, all the way back to the root
  5. if [[ $# -eq 2 ]]
  6. then
  7. filename="$1"
  8. shift
  9. else
  10. filename=wpull.db
  11. fi
  12. if [[ ! -f "${filename}" ]]
  13. then
  14. echo "Error: ${filename} does not exist or is not a regular file" >&2
  15. exit 1
  16. fi
  17. url="$1"
  18. curId=$(sqlite3 "${filename}" 'SELECT id FROM url_strings WHERE url = "'"${url}"'"')
  19. if [[ -z "${curId}" ]]
  20. then
  21. echo "Error: ${url} not found" >&2
  22. exit 1
  23. fi
  24. while :
  25. do
  26. sqlite3 "${filename}" 'SELECT queued_urls.*, url_strings.* FROM queued_urls JOIN url_strings ON queued_urls.url_string_id = url_strings.id WHERE url_strings.id = '${curId}
  27. IFS='|' read -r curId level < <(sqlite3 "${filename}" 'SELECT parent_url_string_id, level FROM queued_urls WHERE url_string_id = '${curId})
  28. if [[ ${level} -eq 0 ]]
  29. then
  30. break
  31. fi
  32. done