Matlab compiler with special character string as input [duplicate] - matlab

This question already has answers here:
How to escape parameter in windows command line?
(3 answers)
Closed 7 years ago.
So I need to run my program in the windows prompt like this:
my_program somestring.
The problem is that somestring can contain characters like &.
I get problems like:
'si' is not recognized as an internal or external command.
Where 'si' is after & in the string.
I just want to read the whole string.
What can I do?
Edit: It seems to work if I put "" around somestring.
But this is not something I can control.

You seem to believe that this error is returned by matlab, however that is not the case.
This error is returned as a result of the command prompt being unable to run your command. As such we can conclude the following:
The string never reaches your matlab program
Changing your matlab code will not help in any way
You already seem to know how to solve it from the side of the input as was also decribed in How to escape parameter in windows command line?. But unfortunately the answer is that there does not appear to be another way.
Conclusion
If you enter an invalid string in the command prompt, there is nothing you can do in matlab to 'make it work'.

Related

Autohotkey / AHK - String as function parameter without " "

Is there any way to define function parameter as string by default, so I could send them without using double quotes?
If you know C++ and want to compile your own version of AHK from the source code, or if you want to make an other script which will insert in the quotes automatically after the fact, then yes. Otherwise no.
And I really don't know why you'd want to do this. Seems terrible in my opinion.
Maybe you're used to legacy AHK? If so, you really should let go of that. Maybe about 10 years ago it was fine to use.

how I can define variable name with " write " command in fortran

I need to define a variable name for different files inside a Fortran code, while I 'm using this commands
open(unit=5,file="plot.sm")
write(unit=zbin_str,fmt='(f5.2)') zbin
plotname="LF_z"//zbin_str//".ps"
write(5,"dev postencap" plotname)
write(5,"toplabel LF for",//zbin_str//)
I'm receiving these errors :
Syntax error, found '//' when expecting one of: ( * <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> ...
write(5,"toplabel LF for",//zbin_str//)
error #6355: This binary operation is invalid for this data type. [PLOTNAME]
write(5,"dev postencap" plotname)
An arithmetic or LOGICAL type is required in this context.
write(5,"dev postencap" plotname)
How I can define the available name inside the Fortran code??
Thanks
Neither of these lines
write(5,"dev postencap" plotname)
write(5,"toplabel LF for",//zbin_str//)
is well-formed; that's what the compiler is trying to tell you.
Beyond that, I'm not sure what you are trying to do or, therefore, how to fix it. Unless you use keywords your Fortran compiler will understand the 2nd argument in a write statement to be the format specifier in which you want to present the output. I can't see how either "dev postencap" plotname or "toplabel LF for",//zbin_str// can be made into a valid format specifier. Perhaps what you want is
write(5,'(a32)') "dev postencap"//plotname
write(5,'(a32)') "toplabel LF for"//zbin_str
Anything more would be based on guesswork. If this doesn't answer your question explain it more clearly if you can.

How to "silence" a Matlab function? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Suppressing a function’s command window output
Suppress Output
Is there a way to "silence" the output of a Matlab function? In other words, if a function generates some displayed text in the command window, is there a way to run it in a quiet mode, where the output is suppressed?
In my case, I am using a third-party function iteratively that displays a lot of text, and I want to find a way to suppress that text without modifying the function itself. I'm thinking there must be some kind of wrapper function like quiet(thirdpartyFunction) that gives this kind of behavior. Or is this wishful thinking?
You can probably use evalc and discard the return value.

Possible to use Powershell to type a command into a third-party command line program?

I have an old, third party, command line, proprietary program which I'm calling from PowerShell.
Once started, this program accepts commands typed in followed by enter (like any other program), but it's very basic. It doesn't have flags, doesn't accept piped in arguments, etc. You have to start the program, type your command, hit enter and parse the results.
Is there a way I can use PowerShell to type in a command and get the resulting output? Right now the best solution I have is to call SendKeys.Send in a background job, but I'm not sure this will work.
Is there a better way?
check out this to see if it would work for you: http://wasp.codeplex.com/
legacy programs are hard to tell, however. this works with standard windows programs.

How to discover command line options (if any) for an undocumented executable of unknown origin?

Take an undocumented executable of unknown origin. Trying /?, -h, --help from the command line yields nothing. Is it possible to discover if the executable supports any command line options by looking inside the executable? Possibly reverse engineering? What would be the best way of doing this?
I'm talking about a Windows executable, but would be interested to hear what different approaches would be needed with another OS.
In linux, step one would be run strings your_file which dumps all the strings of printable characters in the file. Any constants chars will thus be shown, including any "usage" instructions.
Next step could be to run ltrace on the file. This shows all function calls the program does. If it includes getopt (or familiar), then it is a sure sign that it is processing input parameters. In fact, you should be able to see exactly what argument the program is expecting since that is the third parameter to the getopt function.
For Windows, you can see this question about decompiling Windows executables. It should be relatively easy to at least discover the options (what they actually do is a different story).
If it's a .NET executable try using Reflector. This will convert the MSIL code into the equivalent C# code which may make it easier to understand. Unfortunately private and local variable names will be lost, as these are not stored in the MSIL but it should still be possible to follow what's going on.