You are not logged in.

#1 2013-04-23 02:29:52

jjshinobi
Member
Registered: 2013-04-06
Posts: 97

[Solved] How to save a file in /usr/bin/local using gedit as an admin?

In my attempt to run these two programs:

https://github.com/kerchen/export_gr2evernote

https://github.com/spiermar/bookmarks2evernote

I noticed they assumed the default python is python 2. I have python 3.3.1 and 2.6.8. I'm following the instructions at: https://wiki.archlinux.org/index.php/Py … ld_scripts

Created a file with this:

#!/bin/bash
script=`readlink -f -- "$1"`
case "$script" in
/home/Dropbox/export_gr2evernote-master1/*|/home/Dropbox/bookmarks2evernote2/*)
    exec python2 "$@"
    ;;
esac

exec python3 "$@"

I then, tried to save it as p2 under /usr/local/bin/ where the only thing that's there is meteor, node, and npm, and it throws me an error saying I don't have enough permissions.

How do I save p2 as an admin in /usr/bin/local using gedit?

I've searched on the forums 'create a file in /usr/' and I haven't found anything. Can someone please help me?

Last edited by jjshinobi (2013-04-23 05:20:47)

Offline

#2 2013-04-23 02:31:57

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,471

Re: [Solved] How to save a file in /usr/bin/local using gedit as an admin?

Save it to your home dir, then use sudo to chown it and move it.

Otherwise, you can run gedit with gksu or something similar.

Last edited by Scimmia (2013-04-23 02:32:27)

Online

#3 2013-04-23 02:46:54

jjshinobi
Member
Registered: 2013-04-06
Posts: 97

Re: [Solved] How to save a file in /usr/bin/local using gedit as an admin?

I couldn't save it under /home so I saved it under /Dropbox and did:

sudo chown (current user) p2

Then tried to move it, and it doesn't believe p2 is there:

"mv: cannot stat ‘/home/Dropbox/p2’: No such file or directory"

The file and directory DOES exist, what gives?

Offline

#4 2013-04-23 03:16:45

henk
Member
From: Weert, Netherlands
Registered: 2013-01-01
Posts: 334

Re: [Solved] How to save a file in /usr/bin/local using gedit as an admin?

‘/home/Dropbox/p2’ must be '/home/<username>/Dropbox/p2'

Offline

#5 2013-04-23 03:22:13

sidneyk
Member
From: Bonner Springs, KS. USA
Registered: 2011-04-22
Posts: 129

Re: [Solved] How to save a file in /usr/bin/local using gedit as an admin?

jjshinobi wrote:

I couldn't save it under /home so I saved it under /Dropbox and did:

sudo chown (current user) p2

Then tried to move it, and it doesn't believe p2 is there:

"mv: cannot stat ‘/home/Dropbox/p2’: No such file or directory"

The file and directory DOES exist, what gives?

I don't believe you want to be the owner of it. You need root to be owner, since it is in /usr/local/bin/, also I believe it needs to be named python in order to work as designed. Normally, with both versions installed and with default settings, a call to python assumes python3 on Arch. The script intercepts any call to python and if you have a python2 site in your list in the script then python2 gets called, otherwise python3 gets called. Just create the file, as per the wiki (as root), i.e. you could use:

sudo nano /usr/local/bin/python

And make it executable and include your paths to projects as specified and you should be good to go, it is working fine for me.

Offline

#6 2013-04-23 03:58:33

jjshinobi
Member
Registered: 2013-04-06
Posts: 97

Re: [Solved] How to save a file in /usr/bin/local using gedit as an admin?

sidneyk wrote:
jjshinobi wrote:

I couldn't save it under /home so I saved it under /Dropbox and did:

sudo chown (current user) p2

Then tried to move it, and it doesn't believe p2 is there:

"mv: cannot stat ‘/home/Dropbox/p2’: No such file or directory"

The file and directory DOES exist, what gives?

I don't believe you want to be the owner of it. You need root to be owner, since it is in /usr/local/bin/, also I believe it needs to be named python in order to work as designed. Normally, with both versions installed and with default settings, a call to python assumes python3 on Arch. The script intercepts any call to python and if you have a python2 site in your list in the script then python2 gets called, otherwise python3 gets called. Just create the file, as per the wiki (as root), i.e. you could use:

sudo nano /usr/local/bin/python

And make it executable and include your paths to projects as specified and you should be good to go, it is working fine for me.

I moved p2 to bin, edited my projects path with the username in front of home, saved it as python, made it executable (#sudo chmod +x /usr/local/bin/python), removed p2. Ran:

#python evernote2enex.py -m 10

It's still referencing python 3...

"python3: can't open file 'evernote2enex.py': [Errno 2] No such file or directory"

My python file contains this:

#!/bin/bash
script=`readlink -f -- "$1"`
case "$script" in
/home/<user>/Dropbox/export_gr2evernote-master1/*|/home/<user>/Dropbox/bookmarks2evernote2/*)
    exec python2 "$@"
    ;;
esac

exec python3 "$@"

I did everything exactly like the wiki said, what seems to be the problem?

Last edited by jjshinobi (2013-04-23 04:01:12)

Offline

#7 2013-04-23 04:34:15

sidneyk
Member
From: Bonner Springs, KS. USA
Registered: 2011-04-22
Posts: 129

Re: [Solved] How to save a file in /usr/bin/local using gedit as an admin?

jjshinobi wrote:
sidneyk wrote:
jjshinobi wrote:

I couldn't save it under /home so I saved it under /Dropbox and did:

sudo chown (current user) p2

Then tried to move it, and it doesn't believe p2 is there:

"mv: cannot stat ‘/home/Dropbox/p2’: No such file or directory"

The file and directory DOES exist, what gives?

I don't believe you want to be the owner of it. You need root to be owner, since it is in /usr/local/bin/, also I believe it needs to be named python in order to work as designed. Normally, with both versions installed and with default settings, a call to python assumes python3 on Arch. The script intercepts any call to python and if you have a python2 site in your list in the script then python2 gets called, otherwise python3 gets called. Just create the file, as per the wiki (as root), i.e. you could use:

sudo nano /usr/local/bin/python

And make it executable and include your paths to projects as specified and you should be good to go, it is working fine for me.

I moved p2 to bin, edited my projects path with the username in front of home, saved it as python, made it executable (#sudo chmod +x /usr/local/bin/python), removed p2. Ran:

#python evernote2enex.py -m 10

It's still referencing python 3...

"python3: can't open file 'evernote2enex.py': [Errno 2] No such file or directory"

My python file contains this:

#!/bin/bash
script=`readlink -f -- "$1"`
case "$script" in
/home/<user>/Dropbox/export_gr2evernote-master1/*|/home/<user>/Dropbox/bookmarks2evernote2/*)
    exec python2 "$@"
    ;;
esac

exec python3 "$@"

I did everything exactly like the wiki said, what seems to be the problem?

OK. Looking at the 2 scripts you quoted, neither one is using a shbang line to set a python version to call. Without that, the python intercept doesn't even come into play. The problem that I see is the way you are starting it:

#python evernote2enex.py -m 10

Is root really necessary for these if they are in your /home/<user>/Dropbox/ directory. And it appears that you are assuming python3 when you start them that way. If you are going to use that method and they are indeed python2 scripts, then change your command to this:

#python2 evernote2enex.py -m 10

You might try it as your normal user too in case root isn't really required.

Offline

#8 2013-04-23 05:20:25

jjshinobi
Member
Registered: 2013-04-06
Posts: 97

Re: [Solved] How to save a file in /usr/bin/local using gedit as an admin?

sidneyk wrote:
jjshinobi wrote:
sidneyk wrote:

I don't believe you want to be the owner of it. You need root to be owner, since it is in /usr/local/bin/, also I believe it needs to be named python in order to work as designed. Normally, with both versions installed and with default settings, a call to python assumes python3 on Arch. The script intercepts any call to python and if you have a python2 site in your list in the script then python2 gets called, otherwise python3 gets called. Just create the file, as per the wiki (as root), i.e. you could use:

sudo nano /usr/local/bin/python

And make it executable and include your paths to projects as specified and you should be good to go, it is working fine for me.

I moved p2 to bin, edited my projects path with the username in front of home, saved it as python, made it executable (#sudo chmod +x /usr/local/bin/python), removed p2. Ran:

#python evernote2enex.py -m 10

It's still referencing python 3...

"python3: can't open file 'evernote2enex.py': [Errno 2] No such file or directory"

My python file contains this:

#!/bin/bash
script=`readlink -f -- "$1"`
case "$script" in
/home/<user>/Dropbox/export_gr2evernote-master1/*|/home/<user>/Dropbox/bookmarks2evernote2/*)
    exec python2 "$@"
    ;;
esac

exec python3 "$@"

I did everything exactly like the wiki said, what seems to be the problem?

OK. Looking at the 2 scripts you quoted, neither one is using a shbang line to set a python version to call. Without that, the python intercept doesn't even come into play. The problem that I see is the way you are starting it:

#python evernote2enex.py -m 10

Is root really necessary for these if they are in your /home/<user>/Dropbox/ directory. And it appears that you are assuming python3 when you start them that way. If you are going to use that method and they are indeed python2 scripts, then change your command to this:

#python2 evernote2enex.py -m 10

You might try it as your normal user too in case root isn't really required.

I tested out the first ten with:

#python2 export2enex.py -m 10

it worked!

then proceded with

#python2 export2enex.py > exported.enex

The script is fully functional. Thanks man!

Last edited by jjshinobi (2013-04-23 05:37:03)

Offline

#9 2013-04-23 05:43:27

sidneyk
Member
From: Bonner Springs, KS. USA
Registered: 2011-04-22
Posts: 129

Re: [Solved] How to save a file in /usr/bin/local using gedit as an admin?

jjshinobi wrote:
sidneyk wrote:
jjshinobi wrote:

I moved p2 to bin, edited my projects path with the username in front of home, saved it as python, made it executable (#sudo chmod +x /usr/local/bin/python), removed p2. Ran:

#python evernote2enex.py -m 10

It's still referencing python 3...

"python3: can't open file 'evernote2enex.py': [Errno 2] No such file or directory"

My python file contains this:

#!/bin/bash
script=`readlink -f -- "$1"`
case "$script" in
/home/<user>/Dropbox/export_gr2evernote-master1/*|/home/<user>/Dropbox/bookmarks2evernote2/*)
    exec python2 "$@"
    ;;
esac

exec python3 "$@"

I did everything exactly like the wiki said, what seems to be the problem?

OK. Looking at the 2 scripts you quoted, neither one is using a shbang line to set a python version to call. Without that, the python intercept doesn't even come into play. The problem that I see is the way you are starting it:

sudo nano /usr/local/bin/python

Is root really necessary for these if they are in your /home/<user>/Dropbox/ directory. And it appears that you are assuming python3 when you start them that way. If you are going to use that method and they are indeed python2 scripts, then change your command to this:

#python evernote2enex.py -m 10

You might try it as your normal user too in case root isn't really required.

I tested out the first ten with:

#python2 export2enex.py -m 10

it worked!

then proceded with

#python2 export2enex.py GStarred -n exported.enex

The script is fully functional. Thanks man!

Actually, you're not even using the script when starting your python scripts that way. You are explicitly calling either python3 (python) or python2 (python2) to run the indicated python script and not even touching the work around /usr/local/bin/python script. If your python script started with a line like either :

#!/usr/bin/env python

or:

#!/usr/bin/python

And was executable, such that you called it by it's name, i.e. "someprogram.py", then the python script in /usr/local/bin/ would take precedence and effectively intercept the python call and choose the appropriate version of python as long as the path to the directory where "someprogram.py" resides is specified in that /usr/local/bin/python script.

Last edited by sidneyk (2013-04-25 15:40:19)

Offline

Board footer

Powered by FluxBB