Package of utility scripting?

I have some rather hefty bash scripts (several in the 200+ lines range) which I would like to transcode to Julia. I’ve tried this in the past with what could generously be called “limited success”. Now that I have the package manager working (thank you @tomaklutfu!) I was hoping there might be a package to help with making it feels smoother.

I did a Google search, but came up empty. I’m not terribly surprised; Julia doesn’t seem to be built for this kind of thing. I did find a half completed tutorial on “administrative scripting” which seems to be a synonym for what I’m looking for, but it isn’t complete and it even says Julia isn’t made for this task.

As for being more specific about what I’m doing, it’s just basic stuff: making and juggling snapshots, rsync’ing to back ups, system updates, checksumming, checking checksums,… Nothing performance heavy since most of the heavy lifting is done by the various programs, but I figure once you need more than 5 bash functions to make your script readable, you’re already have 5 too many bash functions.

I know I could use Python, but I hate Python and Python hates me.

It is not clear to me what “this” is. Porting Bash to Julia? That’s unlikely to be automated. Or something else, maybe a specific programming task that you can provide details on?

For scripting, I find

useful, and the basic features in

https://docs.julialang.org/en/v1/manual/networking-and-streams/

https://docs.julialang.org/en/v1/manual/running-external-programs/

sufficient.

3 Likes

Thanks for the reply. I have read the manual, however I must admit it seems to have been updated since I last read it.

I guess the issue is that I’m too used to Bash’s little conveniences, which are also the same things that can lead to trouble. Also, I’m not exactly a pro-programmer, but rather a mathematician who occasionally needs Julia for heavy computations.

That said, I’m not sure what advantage Glob has over readdir.

glob is really a standard thing in unix (scripting), if your original bash script doesn’t need glob or similar POSIX tools, then it’s probably very simple?

I think you need to tell us more about what do you need that is available in bash but you don’t know how to do it in Julia

1 Like

I just looked up what that was. I honestly have never heard the term. Yes, I use wild cards and loop over files and directories.

I think you are right, and the first step towards telling you what my problem is is to once more try transcoding. It’s been a few years.

Sorry to waste your time.

1 Like

I’m not so sure, see https://julialang.org/blog/2012/02/why-we-created-julia/

[We want a language that’s] as good at gluing programs together as the shell

Be aware of running with (or -O1 middle ground and possibly also -compile=min) as it can be faster:

$ julia --startup-file=no -O0

See this (and linked from it) post on Julia safer than the usual suspect glue languages: https://julialang.org/blog/2013/04/put-this-in-your-pipe/

Julia and Python are not the only options, there are also Perl (it might hate you more, or I’m ignorant and it’s nice as a bash substitute), and Julia safer applies applies to (Ruby and) Perl 5 also. I just don’t know about Raku (previously named Perl 6), but I think you do not have it preinstalled on Linux. Neither is PowerShell, only on Windows, but you can add it on Linux (and macOS?).

Oh wow, julia --startup-file=no -O0 seems pretty useful. I saw somewhere where you can specify those type of arguments by first having your usual bash shebang and then exec julia... so that will offset the speed issue.

Those links also are interesting. I had not heard that before.

As for why not use something else, it seems to me that if the options are to learn more of something I already know or something new. The first time I thought “maybe I should use something else” I actually turned to Perl. I wanted to write a more sophisticated git filter for my LaTeX documents and Bash with other basic Unix utilities, such as sed, was just awful. When I looked at Perl, it seemed like an unholy mess. So I turned to Julia which I had already been using for my graduate coursework, having gotten tired of Python.

I see much the same now.

1 Like