I'm trying to download some data using a bash script in a Jupyter notebook and having some problems.
I added quotes to the file paths after I received a 'SyntaxError: unexpected character after line continuation character' error.
However, I'm stumped on how to fix the same error on the Wget command.
This is the contents of the cell as I have it now.
%%bash
FILE=apple2orange
URL="https\://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/$FILE.zip"
ZIP_FILE="./datasets/$FILE.zip"
TARGET_DIR="./datasets/$FILE/"
wget -N \$URL -O \$ZIP_FILE
mkdir $TARGET_DIR
unzip $ZIP_FILE -d ./datasets/
rm $ZIP_FILE
I have changed a little on your script. Now it looks like this:
%%bash
FILE=apple2orange
URL="https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/$FILE.zip"
ZIP_FILE="./datasets/$FILE.zip"
TARGET_DIR="./datasets/$FILE/"
mkdir -p $TARGET_DIR
wget -N $URL -O $ZIP_FILE
unzip $ZIP_FILE -d ./datasets/
rm $ZIP_FILE
In bash strings : doesn't need to be escaped. That was the error I think.
It works on my end.
Have a try.
Related
It seems i have succesfully installed ecCodes. At least if i run the selfcheck in the terminal i get the expected response.
If i run the sell script which is supposed to work with ecCodes it seems to cant find the commands though. This is the Response i get:
Does it matter in which Folder ecCodes is installed? Does someone know what my System is missing?
The Shell Script looks like this:
#!/bin/bash
GFS_DATE="20161120"
GFS_TIME="06"; # 00, 06, 12, 18
RES="1p00" # 0p25, 0p50 or 1p00
BBOX="leftlon=0&rightlon=360&toplat=90&bottomlat=-90"
LEVEL="lev_10_m_above_ground=on"
GFS_URL="http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_${RES}.pl?file=gfs.t${GFS_TIME}z.pgrb2.${RES}.f000&${LEVEL}&${BBOX}&dir=%2Fgfs.${GFS_DATE}${GFS_TIME}"
curl "${GFS_URL}&var_UGRD=on" -o utmp.grib
curl "${GFS_URL}&var_VGRD=on" -o vtmp.grib
grib_set -r -s packingType=grid_simple utmp.grib utmp.grib
grib_set -r -s packingType=grid_simple vtmp.grib vtmp.grib
printf "{\"u\":`grib_dump -j utmp.grib`,\"v\":`grib_dump -j vtmp.grib`}" > tmp.json
rm utmp.grib vtmp.grib
DIR="c:\\Users\My Name\Documents\CGTutorial\CGTutorial - Minimal"
node ${DIR}/prepare.js ${1}/${GFS_DATE}${GFS_TIME}
rm tmp.json
I am trying to store the output of my helm command in a variable in bash script and trying to echo it but it return giving an error ..syntax error in expression
Here is my code
MY_VAR=$((helm ls -A -o json))
echo ${MY_VAR}
To execute one command after another you must add && between them.
Also, you do not need double parentheses.
For example:
MY_VAR=$(helm ls -A -o json) && echo ${MY_VAR}
Its because you got double brackets
Change into
MY_VAR=$(helm ls -A -o json)
this solve the problem for me
I'm trying to form a cURL using string concatenation in Python. I have a custom command and I'm not sure if I can use requests for this.
cmd='curl -u admin:'+password+' -F file=#'+package+' -F name='+package+' -F force=false -F install=true http://'+ip+':5101/crx/packmgr/service.jsp'
print(cmd)
Error:
curl -u admin:******** -F file=#abc_xyz.zip
-F name=abc_xyz.zip
-F force=false -F install=true http://8.8.8.8:5101/crx/packmgr/service.jsp
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
sh: line 1: -F: command not found
sh: line 2: -F: command not found
32512
And yes I have tried escape '' as well. Didn't work.
Any help would be greatly appreciated. TIA
Looks like your constructed command has line endings after the package variable, try stripping it from extra symbols:
package = package.strip()
I am trying to create and image from my Python Flask app, but I am still getting this format error and I have no idea why. (I am running it on a Raspberry with Raspbian)
Step 4/5 : RUN echo "test" ---> Running in ca7b48ab3d4e
standard_init_linux.go:211: exec user process caused "exec format
error"
The command '/bin/sh -c echo "test"' returned a non-zero code: 1
Here is my Dockerfile
#!/usr/bin/env bash
FROM python:3.6.1-alpine
WORKDIR /project
ADD . /project
RUN echo "test"
CMD ["python3","careerdigest.py"]
I think that there is a problem with bash, because it says, that it calls this command with sh, but I do not know, what I am missing.
This echo command will be replaced by RUN pip3 install -r requirements.txt to install dependencies.
Thanks for your help.
Okay, I manage to finally run it. I just replace Python image with this one - https://hub.docker.com/r/balenalib/raspberry-pi-python and now it works.
This is my code to download and unzip files from google drive.
fileId = drive.CreateFile({'id': '1tQq-ihnTbRj6GlObBrm17Ob6j1XHHJL2'})
print (fileId['title'])
fileId.GetContentFile('tweets_research.zip')
!unzip tweets_research.zip -d ./
But there are already some files and I want to replace them. It is giving me
this option.
But it doesn't matter whatever I press on my keyboard it's not working.
Use the -o option to overwrite files, e.g.,
!unzip -o tweets_research.zip -d ./
You can echo your choice as input to your command by using a pipe.
in case of rename:
!echo "r"| unzip tweets_research.zip -d ./