LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-27-2018, 03:12 PM   #1
vysero
Member
 
Registered: May 2018
Posts: 137

Rep: Reputation: Disabled
Why this script wont run


I have a script that is supposed create a symlink from the current linux header directory to /usr/src/linux:

Code:
#!/usr/bin/env python 
import os 
import sys 
import subprocess
def _runningKernel():
    result = subprocess.check_output(['uname', '-r']).strip()
    return result
def _kernelHeaderPath(kernelName):
    return os.path.join('/', 'usr', 'src', 'linux-headers-%s' % kernelName)
_linkName = os.path.join('/', 'usr', 'src', 'linux')
_headersPath = _kernelHeaderPath(_runningKernel())
if not os.path.isdir(os.path.join(_headersPath, '.')):
    sys.stderr("Error: Did not the header files directory at %s\n" % _headersPath)
    sys.exit(1)
if (not os.path.islink(_linkName)) and os.path.exists(_linkName):
    sys.stderr("Error: %s is not a symlink.  (Cowardly refusing to overwrite it.)\n" % _headersPath)
    sys.exit(1)
if os.path.islink(_linkName):
    os.remove(_linkName);
os.symlink(_headersPath, _linkName)
So I created a text file in a folder in my home directory and pasted the code into it and saved it as: link. However, when I open a terminal in that directory and run: sudo ./link it says: sudo: ./link: command not found

Isn't ./script the normal way you would run a python script?
 
Old 08-27-2018, 03:22 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,188
Blog Entries: 13

Rep: Reputation: 3602Reputation: 3602Reputation: 3602Reputation: 3602Reputation: 3602Reputation: 3602Reputation: 3602Reputation: 3602Reputation: 3602Reputation: 3602Reputation: 3602
This script is the same one from your other question: https://www.linuxquestions.org/quest...8/#post5894070

How did you manage to run it in that case? Or is this a duplicate of that question, phrased differently?
 
Old 08-27-2018, 03:24 PM   #3
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,068

Rep: Reputation: 1384Reputation: 1384Reputation: 1384Reputation: 1384Reputation: 1384Reputation: 1384Reputation: 1384Reputation: 1384Reputation: 1384Reputation: 1384
Quote:
Originally Posted by vysero View Post
So I created a text file in a folder in my home directory and pasted the code into it and saved it as: link. However, when I open a terminal in that directory and run: sudo ./link it says: sudo: ./link: command not found

Isn't ./script the normal way you would run a python script?
If you're in your home directory (the same directory the file is in), yes. Did you make the file link executable?
Code:
chmod 755 ./link
(Unless it's the sudo command it can't find. Have you used sudo with that user before?)

Last edited by scasey; 08-27-2018 at 03:27 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script wont run from cron Entropy1024 Linux - Newbie 7 04-15-2016 06:31 AM
[SOLVED] script wont run from cront slowerogue Linux - Newbie 9 12-30-2012 10:49 PM
[SOLVED] Perl script wont run - no error, no nothing (this *should* be easy!) Sly Phy Programming 1 08-08-2010 02:41 PM
Cron wont run my shell script shelb Linux - Desktop 4 05-27-2007 10:55 PM
My script wont run on boot Unicron Ubuntu 2 06-18-2006 12:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration