0

I have a shell script that I want to automate downloading tasks, i would like to get response of command to a variable, command defines as follow.

var=wget --ftp-user=MyName --ftp-password=MyPassword --directory prefix=/home/pi/Desktop/FTP_File/ ftp://202.xx.xx.xx/VideoFiles/Video_1.mp4 2>&1

echo check "$var"

i have achieved that after adding 2>&1 at the end of line and command is in "``", i would like to know what is meant by 2>&1 and is there any other way to achieve it?

Viraj Patil
  • 63
  • 1
  • 7
  • Possible duplicate of [How to set a variable to the output from a command in Bash?](http://stackoverflow.com/questions/4651437/how-to-set-a-variable-to-the-output-from-a-command-in-bash) – Oleksandr Kravchuk Mar 20 '17 at 11:06

1 Answers1

0

Have a look at this: http://www.learnlinux.org.za/courses/build/shell-scripting/ch01s04.html

Any program that is written must have some error checking and it should output some message if any error occurs. It is a standard practice to output error messages on stderr, informative messages on stdout.

2>&1 means to display all the prints of stderr and stdout related to a particular command when executed.

Hope I have answered your question.

Gaurav Pathak
  • 1,065
  • 11
  • 28