command line works, but the .sh file does not execute - terminal

here is an image of the .sh file that does not properly execute
defaults write NSGlobalDomain "NSAutomaticPeriodSubstitutionEnabled" NO
this is the command i insert in the command line that does execute

Related

How to add arguments in custom bash commands?

I am trying to add custom variable in a bash script alias command and not able to do it
I added the following in .bash_profile file
alias mvdb='mv ~/dbs/aw ~/dbs/aw-$1'
In the command line I am trying to run a script
mvdb "2017OCT20"
I want the folder named aw to be renamed as aw-2017OCT20 when I run command
This is a job for a function.
mvdb() {
mv ~/dbs/aw ~/dbs/aw-"$1"
}

How to run a .txt file which has Ruby script, without using the ruby command in the command line

I'm attempting to run some ruby script in a .txt file from the command line. If I use the ruby command before I run the command, the output is what was desired, e.g.
ruby file_name.txt 10 40
How could I execute the same command without having to use the ruby command?
If you are on a unix, you put a #!/usr/bin/ruby at the top of it and the bash shell will execute it.
If you are on Windows, I believe you must use the correct suffix, .rb or .rbw.

Run PERL script in BASH

I use 2 BASH scripts which convert text to file with .mlf extension.
Definition of output in 1. script:
outfile="${mid}_textgrid.mlf"
i.e: 1_textgrid.mlf
Script is runned by:
bash /var/scripts/textgrid-to-mlf-refference.sh $1
Definition of output in 2. script:
outfile="${mid}_vtt.mlf"
i.e: 1_vtt.mlf
Script is runned by:
bash /var/scripts/vtt-to-mlf-hypothesis.sh $1
mid(multimedia identifier) is defined in another script that creates these files. These files are used to compare using compare.pl script(written in PERL). I can run this script using terminal: i.e: ./compare.pl 1_textgrid.mlf 1_vtt.mlf
Problem is that I want to run this script automatically with BASH script. I tried it in script using: perl /var/scripts/compare.pl $1_textgrid.mlf $1_vtt.mlf But it didn't work. Can you give me an example how to run it correctly in this script?
I made new script in BASG to run this "comparing":
#!/bin/bash
mid=$1
reff="/home/var/www/vids/$mid/${mid}_textgrid.mlf"
hyp="/home/var/www/vids/$mid/${mid}_vtt.mlf"
out="/home/var/www/vids/$mid/${mid}_wer.txt"
perl /var/scripts/mlf_compare.pl $reff $hyp >> $out

How to execute a shell command in lua without return value

how to execute this shell script
command = SCRIPT_PATH.."/R.sh "..rfu_path..rfu_file_name.." &"
io.popen(command)
without return value?
I want to execute this shell script first. After I called this script it will runs background and my lua code move to next line.
Is it possible?

Running a shell script through AppleScript

This is my first time trying to create a terminal script and then using AppleScript to run the code. I've tested my terminal script line by line in the terminal (it works...), but would like to put it in a file that can be called by applescript. So far, I've created a file called "/Applications/MAMP/htdocs/global_admin/import_database_command_line.sh" where I've saved all of the individual commands, the first being:
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot;
I then use AppleScript to call the script as:
do shell script
"/Applications/MAMP/htdocs/global_admin/import_database_command_line.sh"
Unfortunately, for each line in my script I get an error, such as:
error "/Applications/MAMP/htdocs/global_admin/import_database_command_line.sh:
line 1: : command not found
Any help in coordinating my AppleScript and the file that contains my shell commands would be appreciated.
You need to include #!/bin/sh in the top line of your .sh file
#!/bin/sh
echo "Hello, world!"
You then need to make the script executable:
chmod +x import_database_command_line.sh
This is because the 'do shell script' AppleScript command is expecting to run the shell commands contained within the quotes. It is not expecting to be calling another script as you are doing. Just put your commands within the quotes, separated by semi-colons.
do shell script "/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot; #other_command; #etc"
Link

Resources