# Modify python script

**URL:** <https://community.unix.com/t/modify-python-script/373200>\
**Category:** Shell Programming and Scripting\
**Created:** [July 19, 2018, 2:48pm UTC](https://community.unix.com/t/modify-python-script/373200 "2018-07-19T14:48:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![drew77](https://community.unix.com/user_avatar/community.unix.com/drew77/32/23164_2.png) [@drew77](https://community.unix.com/u/drew77)\
**Post date:** [July 19, 2018, 2:48pm UTC](https://community.unix.com/t/modify-python-script/373200/1 "2018-07-19T14:48:57Z")

</div>

How can I modify this so it uses Seamonkey and goes to [Yahoo Advanced Web Search](https://search.yahoo.com/web/advanced?)

```plaintext
#!/usr/bin/python3
import os
import urllib
google = os.popen('zenity --entry --text="Enter what you want to google: 
" --title="google.py"').read()
google = urllib.quote(google)
os.system('firefox http://www.google.com/search?q=%s' % (google))  

```

Thanks.

---

<div class="post-metadata">

**Author:** ![wisecracker](https://community.unix.com/user_avatar/community.unix.com/wisecracker/32/2800_2.png) [@wisecracker](https://community.unix.com/u/wisecracker)\
**Post date:** [July 19, 2018, 3:53pm UTC](https://community.unix.com/t/modify-python-script/373200/2 "2018-07-19T15:53:44Z")

</div>

> [@drew77](#):
>
> How can I modify this so it uses Seamonkey and goes to [Yahoo Advanced Web Search](https://search.yahoo.com/web/advanced?)
> 
> ```plaintext
> #!/usr/bin/python3
> import os
> import urllib
> google = os.popen('zenity --entry --text="Enter what you want to google: 
> " --title="google.py"').read()
> google = urllib.quote(google)
> os.system('firefox http://www.google.com/search?q=%s' % (google))  
> 
> ```
> 
> Thanks.

I have no idea how you got this script to work with this line:  
` google = os.popen('zenity --entry --text="Enter what you want to google: `  
What is your traceback error as this would certainly crash the script.  
There are two methods to get out of this probable error:  
1) `google = os.popen('zenity --entry --text="Enter what you want to google: " --title="google.py"').read()` on one line.  
OR...  
2)

```plaintext
google = os.popen('zenity --entry --text="Enter what you want to google: " \
--title="google.py"').read()

```

...using the escape '\' character at the end of the 'SPACE' character.  
I would use the first...  
I have no idea at all about 'zenity' so I have to assume the syntax is correct for that \_command\_.  
As for SeaMonkey until I/we know what the 'google.py' script is I/we have no idea...

---

<div class="post-metadata">

**Author:** ![drew77](https://community.unix.com/user_avatar/community.unix.com/drew77/32/23164_2.png) [@drew77](https://community.unix.com/u/drew77)\
**Post date:** [July 19, 2018, 4:18pm UTC](https://community.unix.com/t/modify-python-script/373200/3 "2018-07-19T16:18:48Z")

</div>

I did not write the script and it works fine.

And something got messed up when I pasted it here.

And there is no google.py.

Here is correct script. Run it and you can see how it works.

```nohighlight
#!/usr/bin/python3
import os
import urllib
google = os.popen('zenity --entry --text="Enter what you want to google: " --title="google.py"').read()
google = urllib.quote(google)
os.system('firefox http://www.google.com/search?q=%s' % (google))

```

---

<div class="post-metadata">

**Author:** ![Chubler\_XL](https://community.unix.com/user_avatar/community.unix.com/chubler_xl/32/2077_2.png) [@Chubler\_XL](https://community.unix.com/u/Chubler_XL)\
**Post date:** [July 19, 2018, 8:31pm UTC](https://community.unix.com/t/modify-python-script/373200/4 "2018-07-19T20:31:05Z")

</div>

Don't have zenity or seamonkey installed so this is untested:

```nohighlight
#!/usr/bin/python3
import os
import urllib
yahoo = os.popen('zenity --entry --text="Enter what you want to yahoo:" --title="yahoo.py"').read()
yahoo = urllib.quote(yahoo)
os.system('seamonkey -new-window https://uk.search.yahoo.com/search?&p=%s' % (yahoo))

```

---

<div class="post-metadata">

**Author:** ![drew77](https://community.unix.com/user_avatar/community.unix.com/drew77/32/23164_2.png) [@drew77](https://community.unix.com/u/drew77)\
**Post date:** [July 20, 2018, 6:28am UTC](https://community.unix.com/t/modify-python-script/373200/5 "2018-07-20T06:28:33Z")

</div>

I modified yours a little. Sometimes it works, but most of the time I get..  
It's very frustrating. 🙂

```nohighlight
#!/usr/bin/python3
import os
import urllib
yahoo = os.popen('zenity --entry --text="Enter what you want to yahoo:" --title="yahoo.py"').read()
yahoo = urllib.quote(yahoo)
os.system('seamonkey http://search.yahoo.com/web/advanced/search?q=%s' % (yahoo))

```

---

<div class="post-metadata">

**Author:** ![wisecracker](https://community.unix.com/user_avatar/community.unix.com/wisecracker/32/2800_2.png) [@wisecracker](https://community.unix.com/u/wisecracker)\
**Post date:** [July 20, 2018, 3:26pm UTC](https://community.unix.com/t/modify-python-script/373200/6 "2018-07-20T15:26:00Z")

</div>

> [@drew77](#):
>
> I modified yours a little. Sometimes it works, but most of the time I get..  
> It's very frustrating. 🙂
> 
> ```plaintext
> #!/usr/bin/python3
> import os
> import urllib
> yahoo = os.popen('zenity --entry --text="Enter what you want to yahoo:" --title="yahoo.py"').read()
> yahoo = urllib.quote(yahoo)
> os.system('seamonkey http://search.yahoo.com/web/advanced/search?q=%s' % (yahoo))
> 
> ```

"but most of the time I[/you] get.." what?  
A python traceback error?  
A zenity error?  
A seamonkey error?  
A Yahoo error?  
Please be more specific.

---

<div class="post-metadata">

**Author:** ![drew77](https://community.unix.com/user_avatar/community.unix.com/drew77/32/23164_2.png) [@drew77](https://community.unix.com/u/drew77)\
**Post date:** [July 20, 2018, 6:23pm UTC](https://community.unix.com/t/modify-python-script/373200/7 "2018-07-20T18:23:13Z")

</div>

Running the script pops up the attached box, then I get the error below.

```nohighlight
python3 /home/andy/bin/yahoo_search.py
Gtk-Message: 17:22:50.240: GtkDialog mapped without a transient parent. This is discouraged.
Traceback (most recent call last):
  File "/home/andy/bin/yahoo_search.py", line 5, in <module>
    yahoo = urllib.quote(yahoo)
AttributeError: module 'urllib' has no attribute 'quote'

```

---

<div class="post-metadata">

**Author:** ![jgt](https://community.unix.com/user_avatar/community.unix.com/jgt/32/10703_2.png) [@jgt](https://community.unix.com/u/jgt)\
**Post date:** [July 20, 2018, 8:44pm UTC](https://community.unix.com/t/modify-python-script/373200/8 "2018-07-20T20:44:10Z")

</div>

Saw the original subject and thought it was a Monty Python skit.

---

<div class="post-metadata">

**Author:** ![drew77](https://community.unix.com/user_avatar/community.unix.com/drew77/32/23164_2.png) [@drew77](https://community.unix.com/u/drew77)\
**Post date:** [July 20, 2018, 9:21pm UTC](https://community.unix.com/t/modify-python-script/373200/9 "2018-07-20T21:21:54Z")

</div>

> [@jgt](#):
>
> Saw the original subject and thought it was a Monty Python skit.

Keep your day job. 🙂

------ Post updated at 08:20 PM ------

------ Post updated at 08:21 PM ------

I found the problem.  
I was running it incorrectly.

`python "/home/andy/bin/yahoo_search.py"`
