Author Topic: Write a script?  (Read 2828 times)

0 Members and 1 Guest are viewing this topic.

Offline vlad777

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: 00
Write a script?
« on: May 07, 2016, 06:01:27 pm »
Write a script?
What does it mean?
Dave asks this question here:
Apr 15, 2016 Live Show 0:37:00

I know that you can write shell script for Linux or write a bat file for windows,
but this is useful mostly with commands that come with OS and most other programs don't have
command line interface commands.
I also know you can control blender trough python.

But other than that , when people say "why don't you write a script" i don't know what they mean.
Can someone give me examples?
Many thanks.

Mind over matter. Pain over mind. Boss over pain.
-------------------------
 

Offline stmdude

  • Frequent Contributor
  • **
  • Posts: 479
  • Country: se
Re: Write a script?
« Reply #1 on: May 07, 2016, 06:18:36 pm »
It's a very ambiguous expression, and this is coming from a software guy.

The analogy I can make is telling an EE guy to "Make a circuit".  I.e, pick the tools you know and cobble together a solution to the problem.

Scripting is sort of simplified programming (in some cases, not so simplified) meant to solve small problems efficiently, by providing very flexible tools to do it with (scripting languages are typically very powerful for string manipulation, whilst compiled languages are not).

Seems good?   Well, the down-side is that you usually end up with a very specialized script to solve one particular problem. And, speed (if that matters to you, that a completely different question).

These days, it seems (and I might very well be out-of-date here) are mostly done in Python and JavaScript.  Old farts like me still use Perl.
Whilst you can script to some extent in bat-files, I don't think anyone does that on any serious level. Shell-scripting in Linux is still quite common, usually to automate a few commands together (but they can be made quite complex and powerful).

People who say "write a script" to non-software people are the equivalent to EE people telling rookies in electronics to "just use an op-amp".
Op-amps are very flexible devices, and takes a little while to learn (assuming you already know the basics of circuits), and can be used in a million different ways.

I'm sure everyone and their dog is going to disagree with me, and downplay the complexity. Thing is, to write scripts (or any kind of software), you need basic knowledge like program-blocks, basic logic, loops, types, conditionals, etc, which seem like no-brainers to SW guys (because they've got that way of thinking ingrained in them), but are actually things that regular people _need_ to learn before being able to "write a script".
 
The following users thanked this post: SeanB

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6434
  • Country: us
    • Personal site
Re: Write a script?
« Reply #2 on: May 07, 2016, 06:20:31 pm »
The question is very broad. You can do anything you like with Python, not just control Blender.
Alex
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6434
  • Country: us
    • Personal site
Re: Write a script?
« Reply #3 on: May 07, 2016, 06:23:04 pm »
which seem like no-brainers to SW guys (because they've got that way of thinking ingrained in them), but are actually things that regular people _need_ to learn before being able to "write a script".

When you are coming from a practical perspective, it gets easier because of google and stackoverflow. If code beauty and performance is not a factor, almost anyone can assemble together a simple Python script from bits and pieces.

General understanding of how programming works will be desirable, but I would not call it "learning" and it does not take a lot of time even for complete newbies.
Alex
 

Offline vlad777

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: 00
Re: Write a script?
« Reply #4 on: May 07, 2016, 06:24:00 pm »
What confuses me is: how do you expect a script to control a "random" program or app , that maybe wasn't intended to be scripted.

But reading the comments inside the video someone said "AutoIt " , and looking at wikipedia it seems that this can send keystrokes to an app.
Mind over matter. Pain over mind. Boss over pain.
-------------------------
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6434
  • Country: us
    • Personal site
Re: Write a script?
« Reply #5 on: May 07, 2016, 06:27:13 pm »
What confuses me is: how do you expect a script to control a "random" program or app , that maybe wasn't intended to be scripted.
In general you can't.

Things like AutoIt are useful at times, but generally a big pain. There are plenty of others and they are typically used for automated UI testing, so some of them can make mouse clicks, analyze text under the cursor and do all the stuff humans can do.

But if that advice was specifically about controlling an app that is not designed for that, then more details will be needed. What app are we talking about?
« Last Edit: May 07, 2016, 06:28:51 pm by ataradov »
Alex
 

Offline vlad777

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: 00
Re: Write a script?
« Reply #6 on: May 07, 2016, 06:29:42 pm »
I'm just thinking in general , don't have a problem to solve.
I'm gonna have to look into how python does it and with what apps.
Mind over matter. Pain over mind. Boss over pain.
-------------------------
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6434
  • Country: us
    • Personal site
Re: Write a script?
« Reply #7 on: May 07, 2016, 06:31:47 pm »
I'm gonna have to look into how python does it and with what apps.
Python can't do anything to apps that did not expose proper interfaces.

Python is at the core of Blender, you don't even need to have Python installed, it comes as an integral part in case of Blender.

Most of the time, programs that can be useful when automated are properly designed for automation.
Alex
 

Offline vlad777

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: 00
Re: Write a script?
« Reply #8 on: May 07, 2016, 06:49:15 pm »
Python can't do anything to apps that did not expose proper interfaces.

I think this is the key concept, thanks.
Are these interfaces tied to a particular language?
What do they call those , I am thinking something like API?
Mind over matter. Pain over mind. Boss over pain.
-------------------------
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6434
  • Country: us
    • Personal site
Re: Write a script?
« Reply #9 on: May 07, 2016, 06:55:02 pm »
Are these interfaces tied to a particular language?
Not necessarily. For long-running application that may need automation one of the most common ways is to use sockets. The program simply opens a local port and listens for connections. Any language with networking capabilities will be able to control that program.

What do they call those , a am thinking something like API?
Automation API would be an acceptable name.
Alex
 

Offline vlad777

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: 00
Re: Write a script?
« Reply #10 on: May 07, 2016, 07:01:12 pm »
So sockets and maybe other IPC Inter-process communication I guess then.
Mind over matter. Pain over mind. Boss over pain.
-------------------------
 

Offline vlad777

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: 00
Re: Write a script?
« Reply #11 on: May 07, 2016, 07:09:20 pm »
So when you run a script like that, then you call it a "job" ?
Mind over matter. Pain over mind. Boss over pain.
-------------------------
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6434
  • Country: us
    • Personal site
Re: Write a script?
« Reply #12 on: May 07, 2016, 07:11:21 pm »
So when you run a script like that, then you call it a "job" ?
Call it whatever you like. I don't think there is standard terminology for any of this.

Why not just call it "running a script"?
Alex
 

Offline vlad777

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: 00
Re: Write a script?
« Reply #13 on: May 07, 2016, 07:12:47 pm »
Standard terminology is very useful for googling , just that.
Mind over matter. Pain over mind. Boss over pain.
-------------------------
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6434
  • Country: us
    • Personal site
Re: Write a script?
« Reply #14 on: May 07, 2016, 07:14:14 pm »
Well, when you actually want to do something with a specific app, you just google "<app_name> scripting" or "<app_name> automation" and you'll find all you need to know.
Alex
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 1770
  • Country: us
Re: Write a script?
« Reply #15 on: May 08, 2016, 02:21:10 am »
Many programs have built-in scripting support as well.  Altium and Eagle do, as does AutoCAD.  Even Excel has built-in support for scripting (via Visual Basic for Applications), there's an entire (optional) tab on the ribbon dedicated to it.  In some cases you have to write the script in an external editor, in other cases (like Excel) you can write and debug the script right in the main application.

Done properly, scripting support can allow end users to implement very powerful productivity-enhancing capabilities that the original software developers never anticipated, or that are too specific to a user's needs for them to have bothered with.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: Write a script?
« Reply #16 on: May 08, 2016, 05:12:28 am »
Just to give a real example, I recently had to write a script. I had a server connected to the Internet with a dynamically assigned IP address and a fixed DNS record pointing to the currently assigned IP address.

I wanted to get an email every hour when the current IP of the internet connection does not match the address in the DNS. In this case, the Internet provider was adamant the IP would not change as long as the connection remained, but the truth was the IP was changing every 3 days - usually at the same time of the day.

This is the kind of thing you use scripts for - you need some kind of custom function that is hard to do from standard applications, but easy to do from a Linux Bash shell script.

Exactly the same kind of thing within applications that have scripting available. You might want to draw lines in a graphics package based on a list of GPS coordinates in a CSV file, and the graphics package may have no inbuilt function to do this. You could probably do this with a script file about 10 lines long.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf