0

I am trying to pass a variable stored in shell script and when It runs the wget command it only returns the website without the variables being passed below is the code I have for the shell script

ip=$(curl ipinfo.io/ip)
hostname=$(hostname)
secret=$(pwgen 36 1)
id=$(cat /dev/urandom | tr -dc '0-9' | fold -w 7 | head -n 1)


wget -O sql.sql mydomain.com/test/test.php?id=$id&hostname=$hostname&ip=$ip&secret=$secret

marked as duplicate by dessert command-line Jul 9 '18 at 17:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Your script lacks a shebang. How do you run this script? Did you try the variable notation with curly brackets, e.g. ${id} instead of $id? You have to quote & – I’d do it with double quotes: "mydomain…id=${id}&…" – dessert Jul 9 '18 at 17:47
  • I have not I can now – MrArgon Jul 9 '18 at 17:48
  • After attempting that it is still returning the same file without the send variables – MrArgon Jul 9 '18 at 17:51
  • Did you quote &? ;P – dessert Jul 9 '18 at 17:51
  • no I didn't but after doing that it works thank you so much :P – MrArgon Jul 9 '18 at 17:53

Browse other questions tagged or ask your own question.