In the scripts ddirectory of my dummy project I have created this file without extension and has given executable permission using chmod +x filterList

#!/bin/env python
print "Hello World!"

'python ~/Development/python/listFilter/python/filterList.py $1 $2'

but still when I run this i get error message saying

$ filterList
-bash: filterList: command not found

can anyone help me out with this? I also want to be able to run this from any location of my terminal .

To run a program or script that isn't in a path directory, you need to give at least a relative path to the file:

$ ./filterList

This tells bash where to find the script in question.

this is giving error

$ ./filterList
-bash: ./filterList: /bin/env: bad interpreter: No such file or directory

It is probably /usr/bin/env . Try which env in a terminal.

oh thats correct, but now i don't see any thing in output ,

$ ./filterList
$

even though it has execution permission

$ ll ./filterList
-rwxrwxrwx  1 kystosan  staff  92 Oct 16 08:04 ./filterList

but if i run the python/filterList.py I do get output.

$ python ~/Development/python/listFilter/python/filterList.py
INFO: No List passed to filter

alright by slight changes to my actual filterList exectutable script, I have it executing but not seems to be taking the arguments passed by command line

#! /bin/bash -f
/usr/bin/env python -c "import os; print os.chdir('../python'); import filterList; filterList.main();" 

by running ./filterList results

$ ./filterList '["Hello","Bye"]' H
None
INFO: No List passed to filter

when instead it should print INFO: ["Hello"]

Why don't you write

#!/usr/bin/env python
# -*-coding: utf8-*-
# file: filterList
import os
import sys
fol = os.path.expanduser('~/Development/python/listFilter/python')
sys.path.insert(0, fol)
import filterList
filterList.main()

Another solution would be to make filterList.py executable and create a symlink

ln -s ../python/filterList.py filterList

I had the second one done, but I want to know the standard way for python distributable application, I am guessing that should go to a specific application direcotry that should be in path or i can write a make file that can do the job of creating the symlink.

There are probably many solutions. You can create a symlink in a directory on your path.

Currently I'm using a python app called cherrytree. There is a small python executable /usr/bin/cherrytree which role is to parse command line arguments using argparse, add a folder in sys.path and import the real app meat which is stored in /usr/share/cherrytree. You could study this example.

thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.