Script failing because pushd: not found

I'm trying to run a script and seeing pushd: not found

#!/usr/sh
# stop script on error
set -e

# Check to see if root CA file exists, download if not
if [ ! -f ./root-CA.crt ]; then
  printf "\nDownloading AWS IoT Root CA certificate from AWS...\n"
  curl https://www.amazontrust.com/repository/AmazonRootCA1.pem > root-CA.crt
fi

# Check to see if AWS Device SDK for Python exists, download if not
if [ ! -d ./aws-iot-device-sdk-python ]; then
  printf "\nCloning the AWS SDK...\n"
  git clone https://github.com/aws/aws-iot-device-sdk-python.git
fi

# Check to see if AWS Device SDK for Python is already installed, install if not
if ! python -c "import AWSIoTPythonSDK" &> /dev/null; then
  printf "\nInstalling AWS SDK...\n"
  pushd aws-iot-device-sdk-python
  pip install AWSIoTPythonSDK
  result=$?
  popd
  if [ $result -ne 0 ]; then
    printf "\nERROR: Failed to install SDK.\n"
    exit $result
  fi
fi

The script stops short with:

root@routeserve:~/connect_device_package# ./start.sh

Cloning the AWS SDK...

Cloning into 'aws-iot-device-sdk-python'...

remote: Enumerating objects: 879, done.

remote: Counting objects: 100% (143/143), done.

remote: Compressing objects: 100% (85/85), done.

remote: Total 879 (delta 73), reused 60 (delta 58), pack-reused 736

Receiving objects: 100% (879/879), 337.48 KiB | 2.64 MiB/s, done.

Resolving deltas: 100% (426/426), done.

Installing AWS SDK...

./start.sh: line 20: pushd: not found

Is the git-http package installed?

1 Like

thanks @pavelgl I have installed it and gotten a little further. The next hurdle is pushd: not found

This is a modified bash script. I suspect I'll need to make some tricky work around as pushd appears to be a part of bash. I might even need to install bash.

As well as popd.
I won't analyze your script in details, but you could try changing pushd to cd and popd to cd -

2 Likes

Thanks for the hints. Yes, easily substituted for cd and cd .. in this instance.

I believe Ive seen it written somewhere that installing Bash is not advised but i have no idea why - maybe just do the the storage constraints most routers face?

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.