Guest User

Untitled

a guest
Feb 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. bash -c "some_program with its arguments"
  2.  
  3. ( exec sh -i 3<<SCRIPT 4<&0 <&3 ⏎
  4. echo "do this thing"
  5. echo "do that thing"
  6. exec 3>&- <&4
  7. SCRIPT
  8. )
  9.  
  10. . ./script
  11.  
  12. ( exec sh -i 3<<SCRIPT 4<&0 <&3 ⏎
  13. echo "do this thing"
  14. echo "do that thing"
  15. $(cat /path/to/script)
  16. exec 3>&- <&4
  17. SCRIPT
  18. )
  19.  
  20. % printf 'echo "%s"n' "These lines will print out as echo"
  21. "statements run from my interactive shell."
  22. "This will occur before I'm given the prompt." >|/tmp/script
  23. % ( exec sh -i 3<<SCRIPT 4<&0 <&3
  24. echo "do this thing"
  25. echo "do that thing"
  26. $(cat /tmp/script)
  27. exec 3>&- <&4
  28. SCRIPT
  29. )
  30. sh-4.3$ echo "do this thing"
  31. do this thing
  32. sh-4.3$ echo "do that thing"
  33. do that thing
  34. sh-4.3$ echo "These lines will print out as echo"
  35. These lines will print out as echo
  36. sh-4.3$ echo "statements run from my interactive shell."
  37. statements run from my interactive shell.
  38. sh-4.3$ echo "This will occur before I'm given the prompt."
  39. This will occur before I'm given the prompt.
  40. sh-4.3$ exec 3>&- <&4
  41. sh-4.3$
  42.  
  43. % man set
  44.  
  45. −b This option shall be supported if the implementation supports the
  46. User Portability Utilities option. It shall cause the shell to
  47. notify the user asynchronously of background job completions. The
  48. following message is written to standard error:
  49.  
  50. "[%d]%c %s%sn", <job-number>, <current>, <status>, <job-name>
  51.  
  52. where the fields shall be as follows:
  53.  
  54. <current> The character '+' identifies the job that would be
  55. used as a default for the fg or bg utilities; this
  56. job can also be specified using the job_id "%+" or
  57. "%%". The character '−' identifies the job that
  58. would become the default if the current default job
  59. were to exit; this job can also be specified using
  60. the job_id "%−". For other jobs, this field is a
  61. <space>. At most one job can be identified with '+'
  62. and at most one job can be identified with '−'. If
  63. there is any suspended job, then the current job
  64. shall be a suspended job. If there are at least two
  65. suspended jobs, then the previous job also shall be a
  66.  
  67. −m This option shall be supported if the implementation supports the
  68. User Portability Utilities option. All jobs shall be run in their
  69. own process groups. Immediately before the shell issues a prompt
  70. after completion of the background job, a message reporting the
  71. exit status of the background job shall be written to standard
  72. error. If a foreground job stops, the shell shall write a message
  73. to standard error to that effect, formatted as described by the
  74. jobs utility. In addition, if a job changes status other than
  75. exiting (for example, if it stops for input or output or is
  76. stopped by a SIGSTOP signal), the shell shall write a similar
  77. message immediately prior to writing the next prompt. This option
  78. is enabled by default for interactive shells.
  79.  
  80. % kill -l
  81. > HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH POLL PWR SYS
  82.  
  83. # hitting 'C-z C-z' will run Ctrl+Z (SIGTSTP, suspend as usual)
  84. bind ^Z stuff ^Z
  85.  
  86. # hitting 'C-z z' will suspend the screen client
  87. bind z suspend
  88.  
  89. % fg
  90.  
  91. % bg
  92.  
  93. bash -i <<< 'some_program with its arguments; exec </dev/tty'
  94.  
  95. if [[ -n "START_COMMAND" ]]; then
  96. start_command="$START_COMMAND"
  97. unset START_COMMAND
  98. eval "$start_command"
  99. fi
  100.  
  101. START_COMMAND='some_program with its arguments' bash
  102.  
  103. bash -c "some_program with its arguments;bash"
  104.  
  105. bash -c "
  106. trap 'select wtd in bash restart exit; do [ $wtd = restart ] && break || $wtd ; done' 2
  107. while true; do
  108. some_program with its arguments
  109. done
  110. "
  111.  
  112. 1) bash
  113. 2) restart
  114. 3) exit
  115.  
  116. bash -c "some_program with its arguments; bash"
  117.  
  118. some_program with its arguments &
Add Comment
Please, Sign In to add comment