[英]interactive shell script from InstallAnywhere in console mode
I use InstallAnywhere in console mode in Linux for installation and want to run some interactive shell script after finishing the installation. 我在Linux的控制台模式下使用InstallAnywhere进行安装,并希望在完成安装后运行一些交互式Shell脚本。 By "interactive" I mean that the script should ask some questions and receive user input.
“交互式”是指脚本应提出一些问题并接受用户输入。
I tried to run it with "Execute target file" action, but the script prints nothing to the console (it surely executed because prints debug information to output file). 我尝试使用“执行目标文件”操作来运行它,但是脚本未将任何内容打印到控制台(由于将调试信息打印到输出文件,因此该脚本确实执行了)。 I also tried to bring the script to foreground using "fg %1" (it was the last command in InstallAnywhere), but it did not work too.
我还尝试使用“ fg%1”(这是InstallAnywhere中的最后一个命令)将脚本放到前台,但是它也无法正常工作。
Is there any way to execute interactive script by InstallAnywhere in console mode? 有什么方法可以通过InstallAnywhere在控制台模式下执行交互式脚本吗?
Rather than using a shell script for user interaction, leverage IA to collect the answers you need, stuff them into IA variables, then use those variables in one or more "Execute Script/Batch file" Actions to do the post-install work. 与其使用Shell脚本进行用户交互,不如利用IA收集所需的答案,将其填充到IA变量中,然后在一个或多个“ Execute Script / Batch file”操作中使用这些变量来完成安装后的工作。
Say you want to collect a first name, last name and phone then write those to a file in your installation directory (contrived, I know, but hopefully demonstrative). 假设您要收集名字,姓氏和电话,然后将其写入安装目录中的文件中(我知道,是有希望的,但希望能得到示范)。
$FIRST_NAME$
. $FIRST_NAME$
。 $LAST_NAME$
. $LAST_NAME$
。 $PHONE_NUMBER$
. $PHONE_NUMBER$
。 TRUE
result will execute the jump to "Get User Info". TRUE
将执行跳转到“获取用户信息”的操作。 In other words, a BAD first name or BAD last name or BAD phone number should evaluate to TRUE
. TRUE
。 This will send the user back to the "Get User Info" Target Label. ${MY_VARIABLE_NAME}
to help IA distinguish your variables from its own variables). ${MY_VARIABLE_NAME}
可以帮助IA区分您的变量和它自己的变量)。 A Unix/Linux version might look like this: Unix / Linux版本可能如下所示:
#!/bin/sh
echo <<EOF
Name: $FIRST_NAME$ $LAST_NAME$
Phone: $PHONE_NUMBER$
EOF > $USER_INSTALL_FOLDER$$/$userName.txt
The Windows version is similar: Windows版本类似于:
echo "Name: $FIRST_NAME$ $LAST_NAME$" > $USER_INSTALL_FOLDER$$/$userName.txt
echo "Phone: $PHONE_NUMBER$" >> $USER_INSTALL_FOLDER$$/$userName.txt
Note the use of $/$
which IA converts to the appropriate path separator for the current platform. 请注意
$/$
的使用,IA会将其转换为当前平台的适当路径分隔符。
After the "Execute Script/Batch file" Actions you can add steps to evaluate the success of the Script/Batch file. 在“执行脚本/批处理文件”操作之后,您可以添加步骤以评估脚本/批处理文件的成功。 Add rules on "Jump To Target" Actions to evaluate the value of
$EXECUTE_EXITCODE$
. 在“跳转到目标”操作上添加规则,以评估
$EXECUTE_EXITCODE$
的值。 $EXECUTE_EXITCODE$
is the default variable where the process' exit code is stored by "Execute Script/Batch file" Actions. $EXECUTE_EXITCODE$
是默认变量,通过“执行脚本/批处理文件”操作在其中存储进程的退出代码。
Real-life installation scripts could be more complex than this. 实际的安装脚本可能比这更复杂。 You could collect any number of variables and use them in any number of post-installation script(s).
您可以收集任意数量的变量,并在任意数量的安装后脚本中使用它们。 These scripts then focus on doing the work, not on talking to the user.
这些脚本然后专注于完成工作,而不是与用户交谈。 That should be IA's job.
那应该是IA的工作。
Two parting thoughts: 两个分开的想法:
First, this same technique could be used with a GUI installer, too. 首先,同样的技术也可以与GUI安装程序一起使用。 In fact, mixing GUI and console input actions in the same project extends your installer to both graphical and console target platforms.
实际上,在同一项目中混合使用GUI和控制台输入操作会将您的安装程序扩展到图形和控制台目标平台。 The Post-Install scripts remain the same regardless of how you collect the input.
无论您如何收集输入,安装后脚本均保持不变。
Finally, you should ask your questions (if possible) during Pre-Install. 最后,您应该在预安装过程中提出您的问题(如果可能)。 That way the user can decide to bail on the installation if they can't or won't answer the questions.
这样,用户可以决定是否能够回答或不回答问题。 Asking the questions during post-installation could leave the installation hanging, or force the user to roll back, if they are unwilling or unable to provide the information you need.
如果不愿意或无法提供所需的信息,则在安装后提出问题可能会使安装挂起,或者迫使用户回退。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.