Friday, May 5, 2017

debian - error while executing bash script -> command not found



i made this script here, and get the error





IA-exporto.sh: 13: wget: not found




i tried changing the " by ` and mixed all together and rearranged, but it just won't do..



#!/bin/bash
UNAME="maximilian"
PWD="password"
DATE=`date +%Y\-%m\-%d`

DAY=`date +%d`
MONTH=`date +%m`
YEAR=`date +%Y`

PATH="/root/test/IA"

URL="http://www.my-corpo.com/_backend/index.php?date=$YEAR-$MONTH-$DAY&view=csv"
COMMAND="wget --user=$UNAME --password=$PWD $URL -O $PATH-$DATE.csv"
$COMMAND



i even tryed to set before and after every variable a ", so it looks like



COMMAND="wget --user="$UNAME" --password="$PWD" "$URL" -O "$PATH"-"$DATE".csv"


but when i echo $COMMAND it looks very right, in fact, when i copy it from and insert it, it works..


Answer



You're overriding the $PATH variable, which determines which directories are searched for executables (like wget):




PATH="/root/test/IA"


So the shell is only looking in /root/test/IA for the wget command. Change your variable name to something else.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...