Reputation: 35
I am running a machine translation code in google colab for that I cloned the code into my drive and stored the drive location in a variable:
!PATH='/content/mydrive/My Drive/facebook/unsup'
The cloning was succesfully done in the desired location. The problem arises when I try to run a shell file:
!."$PATH/NMT/get_data_enfr.sh"
it returns
/bin/bash: ./content/mydrive/My Drive/facebook/unsup/NMT/get_data_enfr.sh: No such file or directory
But if I run
!head "$PATH/NMT/get_data_enfr.sh"
It shows the file content.
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
set -e
#
Upvotes: 1
Views: 4489
Reputation: 2813
You have to escape the space with a single backslash.
Example: PATH=/omg/a\ space
Also its a good idea to put the output in " or ' with echo \"${PATH}\"
Upvotes: 1
Reputation: 3201
Can you try running the script as :
sh "$PATH/NMT/get_data_enfr.sh"
Before running it like above, please run the below command :
chmod +x "$PATH/NMT/get_data_enfr.sh"
It seems @dash-o is correct, When you are running the script using .
in front of script, it actually looking for script from the current directory.
It's working for head
command because there the complete path is being passed to head
and it is finding the file at that path but not true while running it.
./path/to/script
actually trying to run the script from the current directory and ignoring the absolute path. But when using sh
and then $PATH
, it actually running from the absolute path.
Upvotes: 2