Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8936691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:16:11+00:00 2026-06-15T10:16:11+00:00

Environment: python 2.6 path=/this/is/an/example/ cmd={‘Foo’: (PATH + ‘sh forExample.sh’), ‘blah’: (PATH + ‘sh secExample.sh’)}

  • 0
Environment: python 2.6
path="/this/is/an/example/"

cmd={'Foo': (PATH + 'sh forExample.sh'), 'blah': (PATH + 'sh secExample.sh')}

for app in cmd.keys():
    print 'app name', app

it prints as expected Foo

However, when I try to access ‘sh forExample.sh’

   for app in cmd.keys():
        print 'app name', app
        run_apps([app])

where run_apps function looks like this..

def run_apps(apps):
        for a in apps:
                print a
                cmdlist = cmd[a][0]
                print cmdlist

It does not give the expected output, but instead gives 's'. I tried varying the value in cmd[a][x], it keeps giving the value of the character which X points to.

Oh and this was the error: /bin/sh: 1: /: Permission denied
I am using Linux, distro: Ubuntu.

any idea what the error is? where I am going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:16:13+00:00Added an answer on June 15, 2026 at 10:16 am

    The value of Foo of your cmd dict is 'sh forExample.sh'.

    So cmd[a][0] will result in the first character of that string.


    Looking at this line

    cmd={'Foo': ('sh forExample.sh'), 'blah': ('sh secExample.sh')}
    

    it seems that you want to have a tuple as value in your dict. To create a one-value tuple, just append a , and your code should work as expected:

    cmd={'Foo': ('sh forExample.sh',), 'blah': ('sh secExample.sh',)}
    

    Now the value of cmd[a] is ('sh forExample.sh',), and accesing it with [0] will yield 'sh forExample.sh' .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working in the Google App Engine environment and programming in Python. I am
Im trying to run this code : #!/usr/bin/env python The example presented at the
Consider this example: >>> import subprocess as sp >>> sp.Popen(notepad2.exe,env={PATH:C:\\users\\guillermo\\smallapps\\bin}) <subprocess.Popen object at 0x030DF430>
I have deployed a Pyramid app using mod_wsgi. I have setup the python path
How can one make recursive Glob() in a VariantDir() environment in Python? The answer
Is there any way I can create a UAC-like environment in Python? I want
Just starting out in python on a pendrive 12.04 Kubuntu environment. I had to
Is it possible to create an environment to safely run arbitrary Python scripts under
ENVIRONMENT: C# I have a table of equivalent values, like this: CHEVR = CHEVROLET
I want to run a csh file from a python script, example, #!/usr/bin/python import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.