I am trying to use aria2c to download a file. The command looks like this:
aria2c --http-user=$USER --http-passwd=$usepw -x 16 -s 100 $urlPath
The command works perfectly from the script when run this way. What I'm trying to do is capture the output from the command to a variable and still display it on the screen in real-time.
I have successfully captured the output to a variable by using:
VAR=$(aria2c --http-user=$USER --http-passwd=$usepw -x 16 -s 100 $urlPath)
With this scenario though, there's a long delay on the screen where there's no update while the download is happening. I have an echo command after this line in the script and $VAR has all of the aria2c download data captured.
I have tried using different combinations of 2>&1, and | tee /dev/tty at the end of the command, but nothing shows in the display in realtime.
Example:
VAR=$(aria2c --http-user=$USER --http-passwd=$usepw -x 16 -s 100 $urlPath 2>&1)
VAR=$(aria2c --http-user=$USER --http-passwd=$usepw -x 16 -s 100 $urlPath 2>&1 | tee /dev/tty )
VAR=$(aria2c --http-user=$USER --http-passwd=$usepw -x 16 -s 100 $urlPath | tee /dev/tty )
VAR=$((aria2c --http-user=$USER --http-passwd=$usepw -x 16 -s 100 $urlPath) 2>&1)
VAR=$((aria2c --http-user=$USER --http-passwd=$usepw -x 16 -s 100 $urlPath) 2>&1 | tee /dev/tty )
VAR=$((aria2c --http-user=$USER --http-passwd=$usepw -x 16 -s 100 $urlPath) 2>&1 ) | tee /dev/tty )
I've been able to use the "2>&1 | tee" combination before with other commands but for some reason I can't seem to capture aria2c to both simultaneously. Anyone had any luck doing this from a bash script?