LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-14-2010, 07:02 AM   #1
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Executing a file of some other directory from the PWD


Hi,

My present working is
Code:
linux:/home/anisha/downloads/mapnik-0.6.1/demo/c++ #
Now I want to run "python scons/scons.py" located in
Code:
linux:/home/anisha/downloads/mapnik-0.6.1/ #
I tried
Code:
../../python scons/scons.py
from the above stated PWD but it resulted in the following:
Code:
bash: ../../python: No such file or directory
What is the way to execute a file of some other directory from the PWD !

Kindly guide.

Last edited by Aquarius_Girl; 01-14-2010 at 07:04 AM.
 
Old 01-14-2010, 07:12 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The space in the directory name is causing the problem. Use autocompletion or escape the space.
 
Old 01-14-2010, 07:14 AM   #3
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
What space are u talking about ?

Kindly quote and show !

EDIT
Is this the space u are talking about ?
python scons/scons.py

Well that's the way the file has to be executed !

Last edited by Aquarius_Girl; 01-14-2010 at 07:16 AM.
 
Old 01-14-2010, 07:55 AM   #4
mjones490
Member
 
Registered: Sep 2005
Distribution: LFS
Posts: 60

Rep: Reputation: 22
If the executable is python and the script is scons.py and it resides in the scons directory, then what you are doing is correct. But if the script resides in the python scons directory, then you need to say:

Code:
../../python\ scons/scons.py
That way bash knows that python scons is the directory where the script lives.
 
Old 01-14-2010, 08:17 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
It looks like you want to run:
python <path>scons.py

<path> can be absolute or relative, but the "python" command still needs to be first.

Please note: In English, the personal pronoun is "you", not "u"
 
Old 01-14-2010, 10:18 PM   #6
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Thanks for bothering to reply !

Quote:
Originally Posted by mjones490
If the executable is python and the script is scons.py and it resides in the scons directory, then what you are doing is correct. But if the script resides in the python scons directory, then you need to say
scons is a directory and it contains scons.py, as seen below:
Code:
anisha@linux:~/downloads/mapnik-0.6.1/scons> ls
sconsign.py  scons-LICENSE  scons-local-1.2.0  scons.py  scons-README  scons-time.py
Now see the following results:
Code:
anisha@linux:~/downloads/mapnik-0.6.1> python scons/scons.py
scons: Reading SConscript files ...

Welcome to Mapnik...

Using previous successful configuration...
Re-configure by running "python scons/scons.py configure".
Now I navigate to 2 directories ahead as follows and tried to execute the script in following 2 ways, and see it results in errors
Code:
anisha@linux:~/downloads/mapnik-0.6.1> cd demo/c++/
anisha@linux:~/downloads/mapnik-0.6.1/demo/c++> python ../../scons/scons.py

scons: *** No SConstruct file found.
File "/home/anisha/downloads/mapnik-0.6.1/scons/scons-local-1.2.0/SCons/Script/Main.py", line 826, in _main
Code:
anisha@linux:~/downloads/mapnik-0.6.1/demo/c++> ../../python scons/scons.py
bash: ../../python: No such file or directory

Last edited by Aquarius_Girl; 01-14-2010 at 10:26 PM.
 
Old 01-14-2010, 10:25 PM   #7
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by pixellany
It looks like you want to run:
python <path>scons.py

<path> can be absolute or relative, but the "python" command still needs to be first.
Thanks for replying !

See post 6, there I've explained what I am doing, kindly tell me where I am going wrong !!

P.S.
I find u easier to type as compared to you! Do you find it offending ??

Last edited by Aquarius_Girl; 01-14-2010 at 10:34 PM.
 
Old 01-15-2010, 03:23 PM   #8
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
As I noted before, the "python" command always needs to come first. Thus, the last example in post #6 does not make sense. (It tries to go up 2 levels and run a file named "python")

In the other example it appears that the program runs but cannot find the file named in the error message. That one is stumping me--it would seem that a program would look for files in the same place--regardless of how it was called.
I suggest you post the portion of the code that is trying to access "SConstruct".

Language:
Many of us do not like to see the texting shorthand---to me, it simply comes across as sloppy and lazy. In the extreme, if every few words is in shorthand, we tend to treat it as a rules violation.
From another perspective, if you are learning any new language, I think you have a responsibility to learn it correctly. I am appalled at anyone who thinks they know English as soon as they are able (with their thumbs) type: "C u l8tr".
 
1 members found this post helpful.
Old 01-15-2010, 11:08 PM   #9
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by pixellany
I suggest you post the portion of the code that is trying to access "SConstruct".
Thanks for guiding !

As from the error output it is clear that Main.py residing in the following directory /home/anisha/downloads/mapnik-0.6.1/scons/scons-local-1.2.0/SCons/Script is using SConstruct file.

I don't know how to attach the Main.py file here. Its code is too lengthy to be posted here !

Last edited by Aquarius_Girl; 01-15-2010 at 11:33 PM.
 
Old 01-16-2010, 05:29 AM   #10
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
just post the portion that calls that file......
 
Old 01-16-2010, 05:36 AM   #11
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
I have posted this function from Main.py !
I hope you can make some sense out of it :

Code:
def _main(parser):
    global exit_status
    global this_build_status

    options = parser.values

    # Here's where everything really happens.

    # First order of business:  set up default warnings and then
    # handle the user's warning options, so that we can issue (or
    # suppress) appropriate warnings about anything that might happen,
    # as configured by the user.

    default_warnings = [ SCons.Warnings.CorruptSConsignWarning,
                         SCons.Warnings.DeprecatedWarning,
                         SCons.Warnings.DuplicateEnvironmentWarning,
                         SCons.Warnings.FutureReservedVariableWarning,
                         SCons.Warnings.LinkWarning,
                         SCons.Warnings.MissingSConscriptWarning,
                         SCons.Warnings.NoMD5ModuleWarning,
                         SCons.Warnings.NoMetaclassSupportWarning,
                         SCons.Warnings.NoObjectCountWarning,
                         SCons.Warnings.NoParallelSupportWarning,
                         SCons.Warnings.MisleadingKeywordsWarning,
                         SCons.Warnings.ReservedVariableWarning,
                         SCons.Warnings.StackSizeWarning,
                       ]

    for warning in default_warnings:
        SCons.Warnings.enableWarningClass(warning)
    SCons.Warnings._warningOut = _scons_internal_warning
    SCons.Warnings.process_warn_strings(options.warn)

    # Now that we have the warnings configuration set up, we can actually
    # issue (or suppress) any warnings about warning-worthy things that
    # occurred while the command-line options were getting parsed.
    try:
        dw = options.delayed_warnings
    except AttributeError:
        pass
    else:
        delayed_warnings.extend(dw)
    for warning_type, message in delayed_warnings:
        SCons.Warnings.warn(warning_type, message)

    if options.diskcheck:
        SCons.Node.FS.set_diskcheck(options.diskcheck)

    # Next, we want to create the FS object that represents the outside
    # world's file system, as that's central to a lot of initialization.
    # To do this, however, we need to be in the directory from which we
    # want to start everything, which means first handling any relevant
    # options that might cause us to chdir somewhere (-C, -D, -U, -u).
    if options.directory:
        cdir = _create_path(options.directory)
        try:
            os.chdir(cdir)
        except OSError:
            sys.stderr.write("Could not change directory to %s\n" % cdir)

    target_top = None
    if options.climb_up:
        target_top = '.'  # directory to prepend to targets
        script_dir = os.getcwd()  # location of script
        while script_dir and not _SConstruct_exists(script_dir,
                                                    options.repository,
                                                    options.file):
            script_dir, last_part = os.path.split(script_dir)
            if last_part:
                target_top = os.path.join(last_part, target_top)
            else:
                script_dir = ''
        if script_dir and script_dir != os.getcwd():
            display("scons: Entering directory `%s'" % script_dir)
            os.chdir(script_dir)

    # Now that we're in the top-level SConstruct directory, go ahead
    # and initialize the FS object that represents the file system,
    # and make it the build engine default.
    fs = SCons.Node.FS.get_default_fs()

    for rep in options.repository:
        fs.Repository(rep)

    # Now that we have the FS object, the next order of business is to
    # check for an SConstruct file (or other specified config file).
    # If there isn't one, we can bail before doing any more work.
    scripts = []
    if options.file:
        scripts.extend(options.file)
    if not scripts:
        sfile = _SConstruct_exists(repositories=options.repository,
                                   filelist=options.file)
        if sfile:
            scripts.append(sfile)

    if not scripts:
        if options.help:
            # There's no SConstruct, but they specified -h.
            # Give them the options usage now, before we fail
            # trying to read a non-existent SConstruct file.
            raise SConsPrintHelpException
        raise SCons.Errors.UserError, "No SConstruct file found."

    if scripts[0] == "-":
        d = fs.getcwd()
    else:
        d = fs.File(scripts[0]).dir
    fs.set_SConstruct_dir(d)

    _set_debug_values(options)
    SCons.Node.implicit_cache = options.implicit_cache
    SCons.Node.implicit_deps_changed = options.implicit_deps_changed
    SCons.Node.implicit_deps_unchanged = options.implicit_deps_unchanged

    if options.no_exec:
        SCons.SConf.dryrun = 1
        SCons.Action.execute_actions = None
    if options.question:
        SCons.SConf.dryrun = 1
    if options.clean:
        SCons.SConf.SetBuildType('clean')
    if options.help:
        SCons.SConf.SetBuildType('help')
    SCons.SConf.SetCacheMode(options.config)
    SCons.SConf.SetProgressDisplay(progress_display)

    if options.no_progress or options.silent:
        progress_display.set_mode(0)

    if options.site_dir:
        _load_site_scons_dir(d, options.site_dir)
    elif not options.no_site_dir:
        _load_site_scons_dir(d)
        
    if options.include_dir:
        sys.path = options.include_dir + sys.path

    # That should cover (most of) the options.  Next, set up the variables
    # that hold command-line arguments, so the SConscript files that we
    # read and execute have access to them.
    targets = []
    xmit_args = []
    for a in parser.largs:
        if a[0] == '-':
            continue
        if '=' in a:
            xmit_args.append(a)
        else:
            targets.append(a)
    SCons.Script._Add_Targets(targets + parser.rargs)
    SCons.Script._Add_Arguments(xmit_args)

    # If stdout is not a tty, replace it with a wrapper object to call flush
    # after every write.
    #
    # Tty devices automatically flush after every newline, so the replacement
    # isn't necessary.  Furthermore, if we replace sys.stdout, the readline
    # module will no longer work.  This affects the behavior during
    # --interactive mode.  --interactive should only be used when stdin and
    # stdout refer to a tty.
    if not sys.stdout.isatty():
        sys.stdout = SCons.Util.Unbuffered(sys.stdout)
    if not sys.stderr.isatty():
        sys.stderr = SCons.Util.Unbuffered(sys.stderr)

    memory_stats.append('before reading SConscript files:')
    count_stats.append(('pre-', 'read'))

    # And here's where we (finally) read the SConscript files.

    progress_display("scons: Reading SConscript files ...")

    start_time = time.time()
    try:
        for script in scripts:
            SCons.Script._SConscript._SConscript(fs, script)
    except SCons.Errors.StopError, e:
        # We had problems reading an SConscript file, such as it
        # couldn't be copied in to the VariantDir.  Since we're just
        # reading SConscript files and haven't started building
        # things yet, stop regardless of whether they used -i or -k
        # or anything else.
        sys.stderr.write("scons: *** %s  Stop.\n" % e)
        exit_status = 2
        sys.exit(exit_status)
    global sconscript_time
    sconscript_time = time.time() - start_time

    progress_display("scons: done reading SConscript files.")

    memory_stats.append('after reading SConscript files:')
    count_stats.append(('post-', 'read'))

    # Re-{enable,disable} warnings in case they disabled some in
    # the SConscript file.
    #
    # We delay enabling the PythonVersionWarning class until here so that,
    # if they explicity disabled it in either in the command line or in
    # $SCONSFLAGS, or in the SConscript file, then the search through
    # the list of deprecated warning classes will find that disabling
    # first and not issue the warning.
    SCons.Warnings.enableWarningClass(SCons.Warnings.PythonVersionWarning)
    SCons.Warnings.process_warn_strings(options.warn)

    # Now that we've read the SConscript files, we can check for the
    # warning about deprecated Python versions--delayed until here
    # in case they disabled the warning in the SConscript files.
    if python_version_deprecated():
        msg = "Support for pre-2.2 Python (%s) is deprecated.\n" + \
              "    If this will cause hardship, contact dev@scons.tigris.org."
        SCons.Warnings.warn(SCons.Warnings.PythonVersionWarning,
                            msg % python_version_string())

    if not options.help:
        SCons.SConf.CreateConfigHBuilder(SCons.Defaults.DefaultEnvironment())

    # Now re-parse the command-line options (any to the left of a '--'
    # argument, that is) with any user-defined command-line options that
    # the SConscript files may have added to the parser object.  This will
    # emit the appropriate error message and exit if any unknown option
    # was specified on the command line.

    parser.preserve_unknown_options = False
    parser.parse_args(parser.largs, options)

    if options.help:
        help_text = SCons.Script.help_text
        if help_text is None:
            # They specified -h, but there was no Help() inside the
            # SConscript files.  Give them the options usage.
            raise SConsPrintHelpException
        else:
            print help_text
            print "Use scons -H for help about command-line options."
        exit_status = 0
        return

    # Change directory to the top-level SConstruct directory, then tell
    # the Node.FS subsystem that we're all done reading the SConscript
    # files and calling Repository() and VariantDir() and changing
    # directories and the like, so it can go ahead and start memoizing
    # the string values of file system nodes.

    fs.chdir(fs.Top)

    SCons.Node.FS.save_strings(1)

    # Now that we've read the SConscripts we can set the options
    # that are SConscript settable:
    SCons.Node.implicit_cache = options.implicit_cache
    SCons.Node.FS.set_duplicate(options.duplicate)
    fs.set_max_drift(options.max_drift)

    SCons.Job.explicit_stack_size = options.stack_size

    if options.md5_chunksize:
        SCons.Node.FS.File.md5_chunksize = options.md5_chunksize

    platform = SCons.Platform.platform_module()

    if options.interactive:
        SCons.Script.Interactive.interact(fs, OptionsParser, options,
                                          targets, target_top)

    else:

        # Build the targets
        nodes = _build_targets(fs, options, targets, target_top)
        if not nodes:
            exit_status = 2

Last edited by Aquarius_Girl; 01-16-2010 at 05:37 AM.
 
Old 01-16-2010, 11:00 AM   #12
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Well---it's pretty easy to see where it's calling "SConstruct". I'm not experienced enough with Python to analyze the code.

One other idea (grabbing at straws maybe...): Have you tried making a soft link to the file that you are executing? Go to the directory where you were trying to run the command and do this:
ln -s <path>/scons.py scons.py

Then, in that directory, you should be able to do:
python scons.py
 
Old 03-09-2010, 02:00 AM   #13
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
pixellany

Thanks for bothering !

This is what I tried and it didn't work:
Code:
anisha@linux-p0mg:~/tarBalls/mapnik-0.7.0/demo/c++> ln -s ../../scons/scons.py .
anisha@linux-p0mg:~/tarBalls/mapnik-0.7.0/demo/c++> ln -s ../../SConstruct .
anisha@linux-p0mg:~/tarBalls/mapnik-0.7.0/demo/c++> python scons.py
scons: Reading SConscript files ...

scons: *** Import of non-existent variable ''env''
File "/home/anisha/tarBalls/mapnik-0.7.0/demo/c++/SConstruct", line 22, in <module>
I couldn't attach the 'SConstruct' file though it is small, size: 1.6 KB !
Error message said : Invalid file

Last edited by Aquarius_Girl; 03-09-2010 at 02:07 AM. Reason: failed to attach file
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pwd: error retrieving current directory: getcwd: cannot access parent directories: Pe bootkernel Linux - General 1 05-05-2008 05:45 AM
Executing a command on every file in a directory asciimonster Linux - Newbie 2 06-14-2004 03:46 AM
pwd and the directory above sneezesnoeze Linux - Newbie 3 03-26-2004 07:18 AM
how to cd to the previously used directory that is no where close to the pwd rootyard Linux - General 3 03-06-2004 10:49 PM
long directory and pwd luegner Slackware 4 11-21-2003 12:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:09 AM.

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
Open Source Consulting | Domain Registration