I need to use GGRAS GIS 7.4.0 on Linux server (Debian 8.10 Jessie) via command line (with flag --exec) and I'm still having troubles with it.

Description: I compile and install GRASS GIS 7.4.0 with no problem on that machine. When I type


in terminal, the text GUI launch. But when I type some command ie.

grass74 v.import input=some_shapefile.shp output=some_file


grass74 /root/grass74/test_loc/PERMANENT v.import input=some_shapefile.shp output=some_file

it gives an

root@maptest:~# grass74 /root/grass74/test_loc/PERMANENT v.import input=/root/test_shp/test_point.shp output=bod 
Cleaning up temporary files... 
Starting GRASS GIS... 
ERROR: </root> is not a valid GRASS Location because PERMANENT Mapset is missing 

So I tried to set up .bashrc file for setting up GRASS GIS environments like at this page Working with GRASS without starting it explicitly.

In bashrc file, I added this lines:

export GISBASE=$GISBASE:/usr/local/grass-7.4.0
export PATH="$GISBASE/bin:$GISBASE/scripts:$PATH"

generate GISRCRC

# Set the global grassrc file to individual file name

echo "GRASS_GUI: text" >> "$MYGISRC"

Then restart server and type "grass74" again, but got this error:

root@maptest:~# grass74
Cleaning up temporary files...
Traceback (most recent call last):
  File "/usr/local/bin/grass74", line 2003, in <module>
  File "/usr/local/bin/grass74", line 1884, in main
  File "/usr/local/bin/grass74", line 1621, in clean_temp
    call([gpath("etc", "clean_temp")], stdout=nul)
  File "/usr/local/bin/grass74", line 245, in call
    return subprocess.call(cmd, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Does anybody knows what I'm doing wrong? Bad setting up environmental variables (bashrc file)? Or something else?

EDIT: I tried to modify command according to mankoff answer. I have created location at:


and the command is:

grass74 EPSG: /root/grass74/pokus1/PERMANENT --exec v.import input=/root/test_shp/test_point.shp output=test_point

but I still get:

Cleaning up temporary files...
Starting GRASS GIS...
Executing <v.import input=root/test_shp/test_point.shp output=test_point> ...
Traceback (most recent call last):
  File "/usr/local/grass-7.4.0/scripts/v.import", line 291, in <module>
  File "/usr/local/grass-7.4.0/scripts/v.import", line 173, in main
    **vopts) == 0:
  File "/usr/local/grass-7.4.0/etc/python/grass/script/core.py", line 413, in run_command
    ps = start_command(*args, **kwargs)
  File "/usr/local/grass-7.4.0/etc/python/grass/script/core.py", line 380, in start_command
    return Popen(args, **popts)
  File "/usr/local/grass-7.4.0/etc/python/grass/script/core.py", line 74, in __init__
    subprocess.Popen.__init__(self, args, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
Execution of <v.import input=root/test_shp/test_point.shp output=test_point> finished.
Cleaning up temporary files...

EDIT - OGRinfo output

root@maptest:~# ogrinfo /root/test_shp/test_point.shp
INFO: Open of `/root/test_shp/test_point.shp'
      using driver `ESRI Shapefile' successful.
1: test_point (Point)
  • Not sure if the following will resolve your issue, but the error 'No Such file or directory' relates to this input=root/test_shp/test_point.shp , you should include the '/' before root, i.e. 'input=/root/test_shp/test_point.shp' – dmci Feb 15 '18 at 10:58
  • No, even with "/" before root doesn't help. Still error 'No Such file or directory'. – david_p Feb 15 '18 at 11:26
  • what is the output of ogrinfo /root/test_shp/test_point.shp? – dmci Feb 15 '18 at 12:01
  • seems valid - see edit above – david_p Feb 15 '18 at 12:09
  • it's not totally clear what you are trying to achieve here. Do you simply want to get started with GRASS via the command-line? Or is there a specific reason you need to launch GRASS and import data from outside a GRASS session? Also, running the above as root, shouldn't cause issues, but it would be probably wise not to. I've tested your v.import command from bash on Debian and it works fine (provided the location & mapset were created). – dmci Feb 15 '18 at 15:50

You don't give the error message from your first example: grass74 v.import input=some_shapefile.shp output=some_file. Because you don't specify a LOCATION and MAPSET it will use the last used one. But the command is incorrect as seen from the manual (https://grass.osgeo.org/grass75/manuals/grass7.html). You need to specify --exec as write you should in your opening sentence.

The second error message implies that you didn't create the /root/grass74/test_loc/PERMANENT LOCATION yet. You could perhaps do this by modifying that command to: grass74 -c EPSG:<SOMETHING> /root/grass74/test_loc --exec v.import input=some_shapefile.shp output=some_file.

See the Batch jobs with the exec interface section of the manual at https://grass.osgeo.org/grass75/manuals/grass7.html and use the syntax there.

Try this:

grass74 -c shapefile ./G
v.import input=shapefile output=dat

If that works, then, if G doesn't yet exist:

grass74 -c shapefile ./G --exec v.import input=shapefile output=dat

And if it does:

grass74 ./G/PERMANENT --exec v.import...
  • Thanks for the answer! I tried it but still get an error. See Edit in question. – david_p Feb 15 '18 at 10:35
  • You're not using GRASS correctly. Get it working interactively at the command line, then worry about non-interaction. You can't start it with -c EPSG: . That is invalid, and why I put the <something> in my answer. Either pass it a file (raster or shapefile) or EPSG code. I suggest starting with simpler use case before you dive in at the level you're trying to work. – mankoff Feb 15 '18 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.