Serial Monitor Error - writing a python script

File script ="/tmp/", FILE_WRITE);
script.print("import urllib2\n");
script.print("import ast\n");
script.print("r = urllib2.urlopen('')\n"); //This line here <------------
script.print("a =\n");
script.print("y = ast.literal_eval(a)\n");
script.print("b = y['results'][0]['example']\n");  // indexing a dictionary that returns an int
script.print("print str(b)");

I’m trying to write a python script into the internal ram of the linino side of my Yun. I’ve tried more simple python scripts printing ints and strings and have been successful. When I enter the line of code with the arrow pointing toward it above, the python script won’t run correctly - nor will the serial monitor output the code script properly if I run this:

Process reading;
String output2 = "";

  output2 += (char);

Serial Monitor outputs this:

import urllib2
import ast
r = urllib2.urlopen('https://example.api

I’d really appreciate some help with this!
Thanks in advance!

to confirm the file correct wrote,

cat /tmp/

at linino console.

before run "/tmp/" you need using Process set permission

chmod 755 /tmp/ or

wrote "/tmp/" without "#!/usr/bin/python\n" and run it as

/usr/bin/python  /tmp/

Thanks for the response. I did see the permissions for the file to be executable, but I'll try your alternative method to invoke the script.

Does it look like there are any errors in how I created the file?

You could confirm if it work by run it at

/usr/bin/python  /tmp/

at linino console.