Changeset 4677cbc
- Timestamp:
- 01/31/2006 03:43:13 PM (18 years ago)
- Branches:
- 10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, 6.2, 6.2.0, 6.2.0-rc1, 6.2.0-rc2, 6.3, 6.3-rc1, 6.3-rc2, 6.3-rc3, 7.10, 7.4, 7.5, 7.6, 7.6-blfs, 7.6-systemd, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, basic, bdubbs/svn, elogind, gnome, kde5-13430, kde5-14269, kde5-14686, kea, ken/TL2024, ken/inkscape-core-mods, ken/tuningfonts, krejzi/svn, lazarus, lxqt, nosym, perl-modules, plabs/newcss, plabs/python-mods, python3.11, qt5new, rahul/power-profiles-daemon, renodr/vulkan-addition, systemd-11177, systemd-13485, trunk, upgradedb, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
- Children:
- 86bb9db5
- Parents:
- d4277d4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
introduction/important/building-notes.xml
rd4277d4 r4677cbc 174 174 175 175 <para>This effectively makes the test suite use the responses in the file 176 as the input to the questions. Impressive, don't you think? Occasionally177 you may end up doing a bit of trial and error determining the exact format178 of your input file for some things, but once figured out and documented you179 can use this to automatebuilding the package.</para>176 as the input to the questions. Occasionally you may end up doing a bit of 177 trial and error determining the exact format of your input file for some 178 things, but once figured out and documented you can use this to automate 179 building the package.</para> 180 180 181 181 <bridgehead renderas="sect3">Using <command>yes</command> to Automate … … 194 194 entering the following commands:</para> 195 195 196 <screen><userinput>cat > blfs yestest1 << "EOF"196 <screen><userinput>cat > blfs-yes-test1 << "EOF" 197 197 <literal>#!/bin/bash 198 198 199 echo -n -e \\n\\n"Please type something (or nothing) and press Enter ---> "199 echo -n -e "\n\nPlease type something (or nothing) and press Enter ---> " 200 200 201 201 read A_STRING … … 205 205 fi 206 206 207 echo -e \\n\\n$A_STRING\\n\\n</literal>207 echo -e "\n\n$A_STRING\n\n"</literal> 208 208 EOF 209 chmod 755 blfs yestest1</userinput></screen>210 211 <para>Now run the script by issuing <command>./blfs yestest1</command> from209 chmod 755 blfs-yes-test1</userinput></screen> 210 211 <para>Now run the script by issuing <command>./blfs-yes-test1</command> from 212 212 the command line. It will wait for a response, which can be anything (or 213 213 nothing) followed by the <keycap>Enter</keycap> key. After entering … … 216 216 response:</para> 217 217 218 <screen><userinput>yes | ./blfs yestest1</userinput></screen>218 <screen><userinput>yes | ./blfs-yes-test1</userinput></screen> 219 219 220 220 <para>Notice that piping <command>yes</command> by itself to the script … … 222 222 string of text:</para> 223 223 224 <screen><userinput>yes 'This is some text' | ./blfs yestest1</userinput></screen>224 <screen><userinput>yes 'This is some text' | ./blfs-yes-test1</userinput></screen> 225 225 226 226 <para>The exact string was used as the response to the script. Finally, 227 227 try it using an empty (null) string:</para> 228 228 229 <screen><userinput>yes '' | ./blfs yestest1</userinput></screen>229 <screen><userinput>yes '' | ./blfs-yes-test1</userinput></screen> 230 230 231 231 <para>Notice this results in passing just the press of the … … 262 262 263 263 <para>Notice that this time the command immediately returned to the shell 264 prompt without having to page through the output. The last example will use 265 the <command>yes</command> command in combination with output redirection 266 to bypass having to page through the output and then providing a 267 <keycap>y</keycap> to a prompt. This technique could be used in instances 268 where otherwise you would have to page through the output of a file (such 269 as a license agreement) and then answer the question of <quote>do you 270 accept the above?</quote>. For this example, another short 271 <application>Bash</application> script is required:</para> 272 273 <screen><userinput>cat > blfsyestest2 << "EOF" 264 prompt without having to page through the output. You may now remove the 265 log file.</para> 266 267 <para>The last example will use the <command>yes</command> command in 268 combination with output redirection to bypass having to page through the 269 output and then provide a <keycap>y</keycap> to a prompt. This technique 270 could be used in instances when otherwise you would have to page through 271 the output of a file (such as a license agreement) and then answer the 272 question of <quote>do you accept the above?</quote>. For this example, 273 another short <application>Bash</application> script is required:</para> 274 275 <screen><userinput>cat > blfs-yes-test2 << "EOF" 274 276 <literal>#!/bin/bash 275 277 276 278 ls -l /usr/bin | more 277 279 278 echo -n -e \\n\\n"Did you enjoy reading this? (y,n) "280 echo -n -e "\n\nDid you enjoy reading this? (y,n) " 279 281 280 282 read A_STRING … … 284 286 fi 285 287 286 echo -e \\n\\n$A_STRING\\n\\n</literal>288 echo -e "\n\n$A_STRING\n\n"</literal> 287 289 EOF 288 chmod 755 blfs yestest2</userinput></screen>290 chmod 755 blfs-yes-test2</userinput></screen> 289 291 290 292 <para>This script can be used to simulate a program that requires you to … … 292 294 agreement before the program will install anything. First, run the script 293 295 without any automation techniques by issuing 294 <command>./blfs yestest2</command>.</para>296 <command>./blfs-yes-test2</command>.</para> 295 297 296 298 <para>Now issue the following command which uses two automation techniques, 297 299 making it suitable for use in an automated build script:</para> 298 300 299 <screen><userinput>yes | ./blfs yestest2 > blfsyestest2.log 2>&1</userinput></screen>300 301 <para>If desired, issue <command>tail blfs yestest2.log</command> to see301 <screen><userinput>yes | ./blfs-yes-test2 > blfs-yes-test2.log 2>&1</userinput></screen> 302 303 <para>If desired, issue <command>tail blfs-yes-test2.log</command> to see 302 304 the end of the paged output, and confirmation that <keycap>y</keycap> was 303 305 passed through to the script. Once satisfied that it works as it should,
Note:
See TracChangeset
for help on using the changeset viewer.