I've just added Lua to my enviroment variables, but now, every time I need to run a lua command, I have to write lua52 main.lua. My question is, is there a way to change that command so that I can write lua main.lua instead?
Yes you can rename lua52.exe into lua.exe.
Related
We have written a scaffold something similar to the vue-cli, we want to verify it through the pipeline.
we have a global command rh-create, once executed, it will create a project skeleton step by step.
I want to know how to write a bash to interact with this command?
I know yes command and printf command, and it seems cannot imitate the arrow up/down key.
Something I found through the internet related to yes and printf:
https://www.baeldung.com/linux/bash-interactive-prompts
Try using a tool called expect instead of bash. It allows you to interact with a program as if you were a user. It depends on and works with the tcl package.
I want to set a directory path to variable using Windows Command Line without any user-interaction. So, like we do in Ubuntu OS:
my_path=$(pwd)
Here, output of pwd will get stored in my_path.
How to do this kind of task in Windows Command Line?
Actually, the more natural way in bash would have been
my_path=$PWD
Taking over this idea to Windows batch language, it would become
SET my_path=%CD%
The main difference is, that in Windows, my_path would end up in the environment automatically, while in bash, you would have to do this manually.
It is possible to supply batch commands directly with the -b flag, but if the commands become very long, this is no longer an option. Is there a way to give the path to an .scm script that was written to a file, without having to move the file into the scripts directory?
No as far as I know. What you give in the -b flag is a Scheme statement, which implies your function has already been loaded by the script executor process. You can of course add more directories that are searched for scripts using Edit>Preferences>Folders>Scripts.
If you write your script in Python the problem is a bit different since you can alter the Python path before loading the script code but the command line remains a bit long.
I noticed that Windows 7 enables to execute .sh files as if they were .bat files. That got me wondering whether it is possible to write a .sh file such that it can be executed in Windows and Linux (let's say bash).
The first thing that comes to my mind is to fabricate an if-statement such that Windows and Ubuntu can deal with it and jump into the according block to execute plattform-specific commands. How could this be done?
Note: I know this is not good practice. I also know that scripting languages like Python are far better suited to solve this problem than a mixed-syntax command line script would be. I'm just curious...
You could use this:
rem(){ :;};rem '
#goto b
';echo sh;exit
:b
#echo batch
It's valid shell script and batch, and will execute different blocks depending on how it's run.
Modify the echo and #echo lines to do what you want.
AFAIK, you can't directly run .sh files from Windows' cmd.exe. For that you'll need a *nix emulation layer to run the shell. Check out Cygwin or Msys/MinGW
I have a Ruby script that I wrote that sorts some files in a jumble of directories based on it's file extension. It would be very difficult to sort it using a GUI, and its easier for me to just put the file in the topmost directory and let the sorter do the work.
Problem is, I'm a bit of a noob to unix scripting. What I want to be able to do is be able to run that sorter script from anywhere on my computer, without having to
cd Desktop/Whatever/Foo
ruby sorterscript.rb
just write sortfolders at the commandline and have the program be run.
I've tested the script many times, and it works fine, I just want a bit more convenience.
Bonus: If possible, and not too difficult, it would be even better if I could have the program run, say, every hour automatically.
As far as your first question goes, you need to do couple of things:
Add a shebang line to your script (make it the first line of the script):
#!/usr/bin/ruby (or whatever the path to the Ruby interpreter's executable is, I forget its exact location)
Make the script executable, either via the Finder's "Get Info" context menu, or via the command line, for example:
chmod 755 my_script.rb
Add the directory location of your script to the PATH environment variable to OS X's launchd.conf file, as described here. You need to add this line:
setenv PATH /path/to/my/script:$PATH (substitute the real path to your script)
As far as your bonus question goes, you can use cron to set up a recurring job. I never really do this, but here's Apple's cron man page to get you started.