how to Give inputs to Lauterbach script? - trace32

I have practice script that take password from dialog box and set it to var. I want to modify it instead of taking password from dialog box it take it from command line like entering parameters to script.
I have read the ref but i can't find it out.

You can call a script with parameters by providing the parameters after the file name. Each parameter should be quoted:
DO my_script.cmm "<my_parameter1>" "<my_parameter2>"
The script can retrieve the parameter like below. In this example the script would fall-back to dialog or error handling if there is no password provided by command line.
PRIVATE &password
PARAMETERS &password
IF "&password"==""
(
;if no password provided from command line,
;then fall back to dialog or error handling.
)
PRINT "Password: &password"
ENDDO

Related

Qt5 QProcess handling arguments with "special" characters

I'm maintaining a Qt5 program that uses QProcess to execute ncftpget on Linux.
The command that I'm attempting to execute is:
ncftpget -E -Z -u username -p 'a#$b1379' 1.1.1.1 /x/y/temp/ update/file
Which simply transfers a file from a server into a local directory. If I execute the above command on the bash command line it works properly.
However, when my Qt5 application executes the same command using QProcess the ftp server replies saying the username/password is not correct. When the password doesn't contain any "special" characters it works properly.
As mentioned by S.M. QProcess isn't executing the command in a shell. So I'm assuming fork() and some version of the exec() call is made. How do I make QProcess do the correct thing here?
I'm assuming that the problem has do to with the special character(s) in the password. When I build my QProcess argument list I specifically make sure the password is surrounded by ' so that the special characters are escaped.
Code snippet:
processFTP.setParent(this->parent());
processFTP.setProcessChannelMode(QProcess::MergedChannels);
// ncftpArgs is a QStringList
// snippet doesn't show complete argument list
ncftpArgs->push_back("-Z");
ncftpArgs->push_back("-u");//username
ncftpArgs->push_back(QString((*phashSettings)[FTPUSERNAME]));
ncftpArgs->push_back("-p");//pw
// password can have special characters when shell executes command.
QString password((*phashSettings)[FTPPASSWORD]);
password.prepend("'");
password.append("'");
ncftpArgs->push_back(password);
ncftpArgs->push_back(QString((*phashSettings)[FTPSERVERIP]));
ncftpArgs->push_back(QString((*phashSettings)[FTPTEMPDIR]));
//beging the ncftpget session
QString sExe = "ncftpget"; //process name
// processFTP is a QProcess object
processFTP.start(sExe, (*ncftpArgs));
bSuccess = processFTP.waitForStarted();
// .... more code to monitor process etc...
The code logs the command and arguments that will passed to processFTP and everything looks correct.
How do I properly set up the arguments and start the QProcess object so that the password argument containing the special characters are properly passed to the executable ncftpget?
And/or how do I go about debugging the problem?
When I build my QProcess argument list I specifically make sure the password is surrounded by ' so that the special characters are escaped.
Do not append or prepend the password with ', remove these lines
password.prepend("'");
password.append("'");
QProcess::start is responsible for proper way of program arguments passing. Besides bash interpreter is not run by this call in your code.

subprocess.popen stream handling

Is it possible to prevent subprocess.popen from showing prompts in the terminal?
Attempting to map a drive but would like to read the prompt for credentials in the script rather than display them to the terminal. The idea being I can carry out actions based on the response.
I am aware the use of shell is frowned upon when using string based commands (for obvious reasons), however I'm controlling the input so am happy with the risk for testing purposes.
I was under the impression that all stdout (interaction) would be parsed into the output_null variable. Instead I am still getting the prompt in the terminal (as illustrated below). I'm either miss understanding how the streams work or I'm missing something. Can anyone enlighten me please
command = "mount -t smbfs //{s}/SYSVOL {m}".format(s=server, m=temp_dir)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output_null = p.communicate()[0]
if "Password for" in output_null:
print 'awdaa'
Terminal Shows
Password for 192.168.1.111:

BuildForge - Passing variables as parameters that are declared as Assing Hidden

I have a build forge job that executes a bat file and intake password as a paramter. If i declare this paramter variable as normal text it works fine. But when I declare password as "Assing Hidden" it doesnt work and throws out error as meniotned below.
Any help is appreciated.
Command I am executing
call MpToSbx.bat SF %account% %password% %REL_NUM% %Track%
Condition
1. Works fine if password is delcared as regular text.
2. When password assigned as hidden it throws out error as below.I feels the command is not iterated correctly some how.
Error Message:
The system cannot find the path specified.
EXEC 'MpToSbx.bat' is not recognized as an internal or external command,
EXEC operable program or batch file.
The most probable cause of this error is that %password% is taken as a single word inside MpToSbx.bat file. To solve this error, first edit that file and change %2 by %~2 (to eliminate quotes in the parameter) and then enclose the password between quotes in the call; for example:
call MpToSbx.bat SF %account% "%password%" %REL_NUM% %Track%

Pre-assign parameter in script

Actually I have trouble naming the title of this post. Because I don't know how to summarize my meaning in a professional way. But I'll explain my question as below:
I'm running a program written by C++, command is:
./VariationHunter_SC
Then it'll let you type in many parameters:
Please enter the minimum paired-end insert size:
Please enter the maximum paired-end insert size:
Please enter the pre-processing mapping prune probability:
Please enter the name of the input file:
Please enter the minimum support for a cluster:
Obviously I need to type in such parameters one by one to run the program; But I have thousands of such jobs, and need to pre-assign such parameters in script, and submit script to computer.
So how can I do that?
thx
Edit
so how can I make parameter-list?
Just like below?:
140
160
0
mrfast.vh
1
Seems the program cannot recognize these numbers, and distribute numbers..
This depends on how the program actually reads the data that you type in - it's likely that its reading stdin, so you could use separate files with the parameters and pass them in via redirection: ./VariationHunter_SC < parameter-file
It's also possible that the program will accept parameters on the command line, but there's no way of really knowing that (or how) except by whatever documentation the program might come with (or by reading the source code, if it's available and there is no other accurate docs).
Simply use the piping character to pipe the contents of a file to your program
example, in a windows command shell:
echo "asdf" | pause
This will pass "asdf" to the pause program. As a result, pause will print a "Press any key to continue" message, then imediately continue because it will receive the "asdf" string as a response.
So, overall, write or use a program that outputs the contents of your file. Call it, then pipe its output to the program that needs the input.
The unix cat command is such a command that writes the contents of a file to output, or to the input of another executable if you are piping the output.

popen and system behaves unexpectedly with multiple quoted file paths

I am trying to execute a dos command from within my C++ program, however soon as I add quotes to the output filepath (of a redirection) the command no longer gets executed and returns instantly. I've shown an example below of a path without spaces, but since paths may have spaces and thus be quoted for the shell to understand it properly I need to solve this dilemma - and I'm trying to get the simplest case working first.
i.e.
The following WORKS:
sprintf(exec_cmd,"\"C:/MySQL Server 5.5/bin/mysqldump.exe\" -u%s -p%s %s > C:/backup.bak",user,password,db_name);
system(exec_cmd);
The following does NOT work (notice the quotes around the output):
sprintf(exec_cmd,"\"C:/MySQL Server 5.5/bin/mysqldump.exe\" -u%s -p%s %s > \"C:/backup.bak\"",user,password,db_name);
system(exec_cmd);
I'm guessing it is choking somewhere. I've tried the same "exec_cmd" in popen to no avail.
Any help/advice is greatly appreciated.
I don't think your shell (cmd.exe) allows redirection to a file name with spaces. I couldn't make my command.com from DOS 6.22 accept it (I don't have a cmd.exe nearby to test).
Anyway, you can use the --result-file option to pass the redirection to the command itself.
mysqldump ... --result-file="file name" ...