What does passing the -xe parameters to /bin/bash do

If you read the man page for bash you’ll find the following at the top of the OPTIONS section: All of the single-character shell options documented in the description of the set builtin command can be used as options when the shell is invoked. In addition, bash interprets the following options when it is invoked… … Read more

How can I fully log all bash scripts actions?

I generally put something similar to the following at the beginning of every script (especially if it’ll run as a daemon): #!/bin/bash exec 3>&1 4>&2 trap ‘exec 2>&4 1>&3’ 0 1 2 3 exec 1>log.out 2>&1 # Everything below will go to the file ‘log.out’: Explanation: exec 3>&1 4>&2 Saves file descriptors so they can … Read more

Run a .bat file in a scheduled task without a window

You could run it silently using a Windows Script file instead. The Run Method allows you running a script in invisible mode. Create a .vbs file like this one Dim WinScriptHost Set WinScriptHost = CreateObject(“WScript.Shell”) WinScriptHost.Run Chr(34) & “C:\Scheduled Jobs\mybat.bat” & Chr(34), 0 Set WinScriptHost = Nothing and schedule it. The second argument in this … Read more

How do I know the script file name in a Bash script?

For reading through a symlink1, which is usually not what you want (you usually don’t want to confuse the user this way), try: IMO, that’ll produce confusing output. “I ran foo.sh, but it’s saying I’m running bar.sh!? Must be a bug!” Besides, one of the purposes of having differently-named symlinks is to provide different functionality … Read more