For some reason when I pass a parameter from one script to another, it does not want to use it.
I have the following code in one script:
Run, %A_AhkPath% "RunAll.ahk" %PathChoice%
The variable %PathChoice% has the Directory that should be used in the second script like so:
Run test.exe %PathChoice%
It is having trouble finding the Directory that the variable is storing, and the directory exist. If I use the actual name of the directory is works just fine. So what am i doing wrong here
Related
I've recently started using fish, and I needed to use a jar file for google's bundletool.
As such, I needed to set up an alias/function for bundletool, and I chose a function since it seems more "fishy".
My function is simple:
function bundletool
java -jar bundletool-all-1.12.1.jar $argv
end
The bundletool jar itself lives at ~/.local/bin, which is on my fish user path:
lase#laser-razer /m/c/U/matth [1]> echo $fish_user_paths
/home/lase/.local/bin /usr/local/go/bin /home/lase/.nvm /home/lase/.cargo/bin /home/lase/.cargo
In a regular shell, I can execute java -jar bundletool-all-1.12.1.jar, and the command runs as expected. However, in the function, fish doesn't seem to know about my fish_user_paths, and reports it cannot find the jar file.
To remedy this, I had to update my function to specify the full path:
function bundletool
java -jar ~/.local/bin/bundletool-all-1.12.1.jar $argv
end
This works, but I feel like I'm doing something incorrectly. Should I be setting up my paths or functions in a different fashion?
Your function will run in the ordinary environment.
It will run with the current $PATH [0] and, more importantly to you, the current working directory.
What happens is this:
java -jar bundletool-all-1.12.1.jar
Will tell java to run the jar found at bundletool-all-1.12.1.jar.
Notably, fish just hands java the string "bundletool-all-1.12.1.jar", and java will then not look at $PATH. It does not care about $PATH. It simply looks at "bundletool-all-1.12.1.jar", and tries to open a file by that name.
And it will find that file, if it is in the current directory.
And that's the reason this worked for you when you executed it interactively - because you happened to be in that directory
And then you tried it with the function, but you tried it from a different directory, and so it didn't work.
This works, but I feel like I'm doing something incorrectly. Should I be setting up my paths or functions in a different fashion?
No, giving the full path to the file instead of relying on the working directory is the right thing to do.
[0]: $fish_user_paths is just a variable you set, that fish will then take care to add to $PATH. $PATH is the actual variable that fish and other tools (including any command fish starts, if it wants to) will use to find commands.
I am trying to configure dymola.mos file, here is an example of changing directory, but when I activate Dymola, it seems the working directory doesn't change at all, even though the log shows Dymola run the script.
My question is:
How could I make the cd command work in the dymola.mos file?
I assume you have activated the option Save startup directory. You can check this with the flag Advanced.StartupDirectory, which will be either 1 or 2. You can simply turn that off or follow the steps below.
From your command log we see that:
Dymola first executes the script <install-path/insert/dymola.mos
Then it restores the settings stored in setup.dymx
Hence the settings in setup.dymx override your working directory.
Instead of using <install-path/insert/dymola.mos you should use a custom .mos script, which is passed as first argument to dymola.exe on startup. This will always be executed last.
Example for Windows
Create the file startup.mos somewhere, e.g. in C:\dymola\startup.mos
Create a shortcut to Dymola.exe, (for Dymola 2021x: C:\Program Files\Dymola 2021x\bin64\Dymola.exe)
Add the .mos script as argument in the Target field in the properties of the shortcut. The result will be:
"C:\Program Files\Dymola 2021x\bin64\Dymola.exe" "C:\dymola\startup.mos"
I have a PowerShell script that works fine:
../third_party/python3/win_x86_64/python.exe fusion.py $args
Now obviously this only works if the current working directory is correct. So I added a variable $abs_parent_path.
Simply adding that in front sadly does not work:
$abs_parent_path/../third_party/python3/win_x86_64/python.exe fusion.py $args
Seems some magic of PowerShell is then breaking down.
Now the question to me is how to build the absolute path to Python and Invocate.
I've been putting my first powershell scripts together for the last couple of hours and I keep seeing an error that I can't seem to get to the bottom of.
I'm using the Powershell ISE tool to write and run the scripts.
To see if its something in my script I've created a super simple test script and I'm seeing the same problem. The entire test script is:
Test;
function Test
{
New-Item C:\Users\jgreen\Desktop\jammer\ -type directory
}
When I hit the Run Script button the error produced is:
Test : The term 'Test' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
If I simply hit the Run Script button again, it work and does the job. I simply do not understand what is wrong. I simply don't get it. Is there a problem with my script or not?
Why would a script that works bomb out the first time after opening the script in PS ISE?
You are calling the function before it is defined. The reason it works the second time, is a result of the first run. When it is ran the first time it's defining the function, so when you run the script the second time it knows what the function is.
You need to declare your function before you invoke it. It works the second time because then it's been declared. Think of how this would work if you were just at a powershell command line and you typed: "Test;" What would you expect to happen?
I have tried running a script in the MATLAB command line and it says
>> run(ex1)
Undefined function or variable 'ex1'.
>> run(exp1.m)
Undefined variable "exp1" or function "exp1.m".
You're using run wrong. You need to encapsulate the script name as a string:
>> run('ex1.m');
You'll need to make sure that your working directory is set to where the script is located, because the above way to call run assumes local referencing.
Please read the documentation on run in the future: http://www.mathworks.com/help/matlab/ref/run.html
However, you can just type in ex1 in the command prompt and it'll still work... as long as you're in the working directory of where the script is run, and ensuring that you don't have any variables in your workspace that have the same name as the script file:
>> ex1