The forum

Trying to learn to write script

Did I misunderstand?

Author Replies
Jump to the page: 1 - 2
steve723 Tuesday 16 July 2013 at 3:07
steve723Anonymous

I am reading the documentation from your web site. My script dosn't seem to work.  Is your documentation for version 4.2.1, or did I miss something. Yes I saved as a .txt file.

#!/bin/bash

[ “$PLAYONLINUX” = “” ] && exit 0

source “PLAYONLINUX/lib/sources”


POL_SetupWindow_Init


POL_SetupWindow_message “Hello World!” “My first message”


POL_SetupWindow_Close

exit



Edited by steve723

Ronin DUSETTE Tuesday 16 July 2013 at 3:12
Ronin DUSETTE

lol. no. I mean, that is kind of right, but how did you try and run it?

Please:
Post debug logs & full computer specs in first post
No private messages for general help, use the forums
Read the wiki, Report broken scripts
Ronin DUSETTE Tuesday 16 July 2013 at 3:22
Ronin DUSETTE

Also, do you know any BASH at all? You really should know basic scripting and be comfortable with a command line.

All scripts should be saved as scriptname.pol

To run custom scripts:

PlayOnLinux -> Tools -> run a local script -> choose script, and run it

So, I mean, dont just follow it, you have to understand what these functions do, otherwise you wont be able to write them.

source “PLAYONLINUX/lib/sources”

Quote


You forgot a $ in front of PLAYONLINUX, as that is a variable.

So, you really need to watch out for syntax, spelling, and everything. This is something we cannot teach, and that you will have to do reading on and practice. You really want to learn BASH, as that will help a lot.

Look at this, and tell me whats different, because this works fine:


#!/bin/bash
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

POL_SetupWindow_Init

POL_SetupWindow_message “Hello World!” “My first message”

POL_SetupWindow_Close
exit

Please:
Post debug logs & full computer specs in first post
No private messages for general help, use the forums
Read the wiki, Report broken scripts
steve723 Tuesday 16 July 2013 at 4:09
steve723Anonymous

Yes the variable error became painfully obvious once I opened the script in Kate which hilights variables in green. I also resaved in .pol. I then compared my script with what you show and saw that it seemed to be the same. I tried it and still nothing.

Lets see scripts don't always work as they should and the wine gecko never downloads when creating a VD and we already tried redoing POL initiaul config. I am woundering if my Linux system got broken somehow. I already tried konsole > sudo apt-get update && apt-get dist-upgrade . I don't know what it could be.
Ronin DUSETTE Tuesday 16 July 2013 at 4:15
Ronin DUSETTE

I dont know, but it really seems like that shouldnt be an issue.

If run that script exactly as it is, exactly like I said, it pops up with hello world. I just used it.

Let me guess; you are running ubuntu 13.04?

Please:
Post debug logs & full computer specs in first post
No private messages for general help, use the forums
Read the wiki, Report broken scripts
steve723 Tuesday 16 July 2013 at 4:47
steve723Anonymous

Isin't that Raring Ringtail. Then yes. but kde version.

steve7233@steve7233-HP-Pavilion-dv6-Notebook-PC:~$ uname -a
Linux steve7233-HP-Pavilion-dv6-Notebook-PC 3.8.0-25-generic #37-Ubuntu SMP Thu Jun 6 20:47:07 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Edited by steve723

steve723 Tuesday 16 July 2013 at 4:54
steve723Anonymous

#!/bin/bash
[ “$PLAYONLINUX” = “” ] && exit 0
source “$PLAYONLINUX/lib/sources”

POL_SetupWindow_Init

POL_SetupWindow_message “Hello World!” “My first message”

POL_SetupWindow_Close
exit
Ronin DUSETTE Tuesday 16 July 2013 at 8:13
Ronin DUSETTE

Ok, so, I will say right off the bat, that ANYTHING but 12.04.x at this time is just a beta. I have been running Kubuntu 12.04.2 64 bit, and it works great. Anything but LTS versions of Ubuntu are BETA versions, and use experimental software and configs.

After everything that has been causing your system issues, Im willing to bet that your OS is screwed. I recommend reinstalling you OS with Kubuntu 12.04.2 LTS (ONLY LTS) and trying that. Your system shouldnt have this many issues, and I think that in your quest to get stuff working, your system got jacked up. I have done it myself MANY times. hahahaha. It happens. Thats why backups are you friends.

At this point, I think thats the best solution.

As for your script, dont post it here. You need to read and test on your own. We cannot teach you BASH or scripting in general. Google will be your best buddy for learning that. Everything that is used in scripts is simply BASH with python functions, but you need to learn basic BASH and Linux command line basics before writing scripts. Im still a beginner when it comes to this too, so Im right there with you.

Please:
Post debug logs & full computer specs in first post
No private messages for general help, use the forums
Read the wiki, Report broken scripts
Quentin PÂRIS Tuesday 16 July 2013 at 9:44
Quentin PÂRISAnonymous

(.pol is NOT an extension for scripts yet. Be careful, .pol files have another specification
petch Tuesday 16 July 2013 at 12:42
petch

Some hint for those that develop scripts: there's a faster way to run them than thru Tools > Run local script > It's not signed are you sure > Yes I'm sure
You can also run them using playonlinux-bash, like
$ playonlinux-bash scriptname
It makes for a much faster and painless turnover, specially if you can use that command as a "compile" command in your favorite editor...
steve723 Tuesday 16 July 2013 at 16:10
steve723Anonymous

Some hint for those that develop scripts: there's a faster way to run them than thru Tools > Run local script > It's not signed are you sure > Yes I'm sure
You can also run them using playonlinux-bash, like

$ playonlinux-bash scriptname

It makes for a much faster and painless turnover, specially if you can use that command as a "compile" command in your favorite editor...

Quote from petch


steve7233@steve7233-HP-Pavilion-dv6-Notebook-PC:~$ $ playonlinux-bash DJYoshaBYD.pol
$: command not found

I saved his scipt to see if it would execuite.  It did but, it only said Hello. It didn't say Hello World just Hello. Thats furthur than I get. I wonder if Libre Office Writer put hidden formatting codes in mine. Which editor should I use. Kate?
petch Tuesday 16 July 2013 at 17:40
petch

$ is the traditional symbol of normal user's prompt, it shouldn't be typed
steve723 Tuesday 16 July 2013 at 17:48
steve723Anonymous

I noticed. Rokie Linux mistake.

Why dosn't this work:?
steve7233@steve7233-HP-Pavilion-dv6-Notebook-PC:~/Documents$ playonlinux-bash script_Learning.pol
[main] Message: PlayOnLinux (4.2.1) is starting
[clean_tmp] Message: Cleaning temp directory
Script started script_Learning.pol
bash: script_Learning.pol: No such file or directory

steve7233@steve7233-HP-Pavilion-dv6-Notebook-PC:~/Documents$ ls
DJYoshaBYD.pol POL script Learning.pol python2-20130628-161441.kcrash.txt
Lotrol Installer script.txt POL script_Learning.pol Relif society Presidency.odt
muon-updater-20130511-071230.kcrash POL script-Learning.pol UntitLotrol Installer script.txt
Playonlinux install scripts POL script Learning.txt
POL script Learning.odt pylotropatch.txt

As you can see the file does exist. I even tried puting quotes around the file name. I can run it just fine from playonlinx just not from BASH.
petch Tuesday 16 July 2013 at 17:51
petch

Some space or case issue (Linux is case sensitive)?
I can't really tell where filenames start and end in your list
Quentin PÂRIS Tuesday 16 July 2013 at 18:41
Quentin PÂRISAnonymous

Really .pol is not the extension meant for scripts. You should not use it when you are writting scripts
steve723 Tuesday 16 July 2013 at 18:44
steve723Anonymous

This is the best I have gotten so far:
http://www.flickr.com/photos/56377873@N04/9302311902/

Here is my script. I have some JAVA programming experiance, so I thought what it might be in case the documentation was for an earlyer version of POL and then tried several things to get the output to formate correctly.


.#!/bin/bash
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

POL_SetupWindow_Init

POL_SetupWindow_message Hello_World My_first_message

POL_SetupWindow_Close
exit
petch Tuesday 16 July 2013 at 19:31
petch

Hi,
Be sure you use "real" double quotes (ASCII character 34) everywhere, see in previous versions of the script above the difference between the
[ "$PLAYONLINUX" = "" ] && exit 0

line and for example
POL_SetupWindow_message “Hello World!” “My first message”

That use different quotes. Use the first kind only, it's probably why you have issues with your quotes.
Probably some editor or some copy&paste playing tricks on you.

Edited by petch

steve723 Tuesday 16 July 2013 at 19:36
steve723Anonymous

I got it!


.#!/bin/bash
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

POL_SetupWindow_Init

POL_SetupWindow_message "Hello World!" " My first message"

POL_SetupWindow_Close
exit

I started using computers in 1982 and I have always hated how Quatations and space have to be just in the exact right place else your program or script will fail.

Now I can proceed furthur in the script documentation.
steve723 Tuesday 16 July 2013 at 19:44
steve723Anonymous

Hi,
Be sure you use "real" double quotes (ASCII character 34) everywhere, see in previous versions of the script above the difference between the

[ "$PLAYONLINUX" = "" ] && exit 0

line and for example
POL_SetupWindow_message “Hello World!” “My first message”

That use different quotes. Use the first kind only, it's probably why you have issues with your quotes.
Probably some editor or some copy&paste playing tricks on you.

Quote from petch


I discovered this before I read your post. I hate that some editors do that. You would think after all these years they would stop making those kinds of programming code or at least make it an option to turn them on if you want some different looking qoute marks but then you know they are on. Never use Libre Office writter to write a POL script unless you know how to turn that annoyance off. From now on I will use Kate.

Edited by steve723

Ronin DUSETTE Tuesday 16 July 2013 at 20:07
Ronin DUSETTE

Ah. I've always named the scripts .pol. For some reason I want to say I was told to, but I'm likely wrong.

Please:
Post debug logs & full computer specs in first post
No private messages for general help, use the forums
Read the wiki, Report broken scripts

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmcayonlinux.com