Ubuntu :: Python Works In Interpreter But Not Actual Script?
Aug 17, 2010
I wrote a script to use egrep to search files for '#!/usr/bin/python' so I could tell what my Python scripts were/where they were. It grabs 'ls' and separates it into an array. It uses ls -F so I can pop anything with a / in it; giving me just files. It then egrep's them. Here's the code.
Code:
#!/usr/bin/python
import commands as com
ls = com.getoutput("ls -F")
ls = ls.split("
[Code]....
When I run all that code in the interpreter, it works. If I run it from Bash (eg ./egrep) it throws me an error like this 'egrep: [Screenshot.png]: No such file or directory' for every file in the directory. Also, it doesn't filter out the directories either.
I am using ubuntu hardy and python 2.6.5 (built from sources). For a custom python packager I need to rebuild python interpreter (python executable). I am new to linux and don't have much knowledge of gcc and other stuff. Here is the process:1. Copy python.c as myapp.c. myapp.c is in the same directory (python2.6.5) in which I have all the required files. 2. Using the syntax from makefile of python sources, here is my first command to produce myapp.o
Code: gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I/home/zeno/installed/Python-2.6.5/Include -fPIC -DPy_BUILD_CORE -c myapp.c -o myapp.o This produce myapp.o but throws a warning:
Code: myapp.c:24:2: warning: no newline at end of file Next is to produce the executable or python interpreter: Code: gcc -pthread -Xlinker -export-dynamic -o $@ myapp.o -L. -lpython2.6 -lpthread -ldl -lutil -lm -o myapp This is causing an error: Code: /usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o: In function `_start': (.text+0x18): undefined reference to `main'
I downloaded a Perl script from off a page on the Internet, and tried to run it. It displayed its source in the web browser. First of all, I am in the cg-bin containing my cgi file and the file permissions are set to 755. I open the Terminal in this folder and run ls, which lists my file called hello.cgi; I run hello.cgi, and get a not found error, and run ./hello.cgi and get source code less comments:
Code:
me@fast:~/Files/Website/perl-dropdown/cgi-bin$ ls hello.cgi redir.cgi me@fast:~/Files/Website/perl-dropdown/cgi-bin$ hello.cgi
[code]....
Next I open my Synaptic and search for perl, so I can reinstall it. I find nothing. I navigate to /usr/bin and eventually find perl and perl5.xx as well.
I have a partially completed interpreter that has first-calss functions and can store scopes in variables. That way it is possible to implement a simple class like this:
Code:
MyClass = func () { value = 0; setValue = func (x) value = x;;
[code]....
But what about inheritance, and what if I want to know the type of the object?
Our Matlab users met the problem in Ubuntu while using Latex interpreter in Matlab. Namely, eps and pdf files generation out of Matlab plot outputs plot legend and axes lables incorrectly. All the letters are mixed, impression that character spaces are too dense. We can't blame Matlab, since exactly the same examples with the same Matlab version work fine on CentOS. We tested Ubntu 9.10, 10.4 and 10.10 -- same problem. Matlab version R2010b.
In addition, jpg, png generated with no problems. It's eps and pdf only Matlab example: plot(1:1:10) xlabel('example','Interpreter','latex') ylabel('ExAmPlE','Interpreter','latex') a=legend('EXAMPLE example ExAmPle') set(a,'Interpreter','latex','Fontsize',13) print -depsc2 figure1 I am attaching a PDF, looks same as eps, but easier to display.
I have installed fc11 x86_64 on my machine. When I try to install .bin files, it displays 'ld-linux.so.2 bad elf interpreter no such file or directory' error. I have also installed glibc but it didn't fix the problem.
I just wanted to install Maya 2010 on Fedora 12 x86_64, but setup alway ends with the following error (right after having started that):
Code: bash: ./setup: /lib/ld-linux.so.2: bad ELF interpreter Autodesk recommends Fedora 9 for Maya, but I wanted to give it a try on F12. So before giving up on that one, I've got some questions:
1. What's an ELF interpreter, anyway?
2. Is there any workaround for that problem, or do you have some suggestions on what I might try?
As some of you know that I am new to this forum. I have another problem that I got stuck on. I have this file called "Fib.rbb" and my instructor told us to write an interpreter program by using Fib.rbb.
"You are to write an interpreter in Perl for Rongs Basic Basic (RBB) as explained in class. The BNF description for RBB and a test file called Fib.rbb are part of the RBB.zip file which is available in the Course Documents folder on blackboard. If you call your interpreter myIntp.pl, you would execute the program via perl myIntp.pl Fib.rbb
I am installing Oracle 11g on Oracle Enterprise Linux 5.0 32 bit (virtual machine)i did all the mandatory steps, i am trying to run the installer but i am facing the below:bash: ./runInstaller: /bin/sh: bad interpreter: Permission deniedknowing that the run isntaller is found in an iso file, in which i linked the VMwarre CD/DVD drive to it
i am working with ad hoc network but the problem is not getting any good documentation of how to compile c++ code then how to add the code into Tcl intrepreter and how to work with make file. i want to run my own algorithm using c++ and then want to incorporate it into tcl interpreter and then want to run.
I have it so that an Env object contains all the variables in the current scope, and the parent scope. You can also save them to variables like objects, and my idea is to use the "." operator to get values from them.
First, how do I assign to them? I currently have it that only a variable name can be assigned to, but you should be able to assign to an "obj.value" expression, too. How do I keep track of what variable to set and still be able to say it in an expression and have it evaluate to the variable?
Second, these object don't really have a "type", they're just containers that contain any values you want under any name you want. How can I, for example, define a primitive "boolean" object and have things like if statements recognize it?
in ubuntu 10.10, I have installed python 2.7. I would like to use apt-get to install packages to this version of python but I haven't been able to figure out howThings I have tried without success:changing the symlink at /usr/bin/python to point to /usr/bin/python2.7 - even after doing this apt-get still installs stuff to python2.6.Set up python2.7 as the primary alternative using update-alternatives - doesn't work
Would a representative from each Linux distro be kind enough to tell me what the command is for installing the Ruby interpreter in their distro? In Gentoo it is "emerge Ruby".
I've been running SQL-Ledger on Centos 5.5 (x86_64) for some time. At some point in time I must have done something to either perl or CPAN and I now get the following error in SQL-Ledger. Not an ARRAY reference at SL/Form.pm line 1047. Attempt to free unreferenced scalar: SV 0x18034630, Perl interpreter: 0x17363010 during global destruction. Attempt to free unreferenced scalar: SV 0x18034630, Perl interpreter: 0x17363010 during global destruction
I'm studying Information Technology and doing Linux as part of it. One of the questions in my text book is: Describe three different ways to start a command line interpreter when using the Gnome desktop of openSUSE Linux. I can't for the life of me make sense out of it.
If say, I want to read the input given by user at the command prompt and write a code to execute the cmd given then which commands do i use to implement this ( Im writing the code in C )?
I have a Python script that I run which needs to execute under a special environment, so I would run the program like so from my working directory (~/project/src):
python manage.py shell
This opens up an interactive shell for me to start typing my own commands.I have another set of administrative activities that I would like to house in another directory (~/project/admin). The manage.py is really finicky about running from the working directory. So, to make this whole thing work, I made a script which starts off like so:
#!/usr/bin/python ../src/manage.py shell
There are a couple problems with this. The first is that it doesn't work:
/usr/bin/python: can't open file '"/../src/manage.py" shell': [Errno 2] No such file or directory
How do you specify multiple parameters to the interpreter?How do I change the working directory?
I have a function definition in a Python 2.x script which take a tuple as one of its arguments, but 2to3 has no answers nor any of my searching on how to represent the same in Python 3.x
I've been having some problems with my desktop. My windows and my sidebar work fine, it's just nothing updates on my actual desktop(like the wallpaper, files, etc.). For example, if I mouseover one of my files on my desktop, nothing happens. I can right click on it and it comes up with the right menu, but it doesn't select the file or anything. I just changed my wallpaper and nothing happened.
I'm well aware this is a common issue among Linux users, but have exausted every method I've researched.
On Xubuntu, I have a small set of USB speakers. Now, the system does detect the output. The mute and volume controls on the speakers work properly (I can see the sound bar move on the screen when doing so).
I've tried various applications such as pavucontrol, to try and fix the problem.
When I try playing audio, sound bars are moving in pavucontrol, but alas, no actual audio from the speakers.
Having just spent many hours going through my entire photo collection tagging, rotating and editing (red eye, cleaning up etc), I am now sat with the window open deciding whether or not it's safe to close it.
I cannot find a save or apply button so I'm not sure if these changes are only made in F-spot itself or if I have to do anything else to make sure it saves to the files.
I DID check the option about storing data in the files where possible but I don't want to just assume it and have to do all this again.