File: stdin.sh

package info (click to toggle)
nco 5.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 38,260 kB
  • sloc: ansic: 84,963; cpp: 28,654; sh: 14,071; perl: 5,996; makefile: 2,009; lex: 1,009; python: 127; csh: 40
file content (45 lines) | stat: -rw-r--r-- 1,264 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Usage:
# chmod 755 ~/stdin.sh
# Invoke stdin.sh with stdin_tst.sh as described in that file
if [ -p /dev/stdin ]; then
    printf "[ -p /dev/stdin ] is true\n"
else
    printf "[ -p /dev/stdin ] is false \n"
fi
if [ ! -t 0 ]; then
    printf "[ ! -t 0 ] is true\n"
else
    printf "[ ! -t 0 ] is false\n"
fi
if [ -z "${TERM}" ]; then
    printf "[ -z \"\${TERM}\" ] is true\n"
else
    printf "[ -z \"\${TERM}\" ] is false\n"
fi
if [ -z "${PS1}" ]; then
    printf "[ -z \"\${PS1}\" ] is true\n"
else
    printf "[ -z \"\${PS1}\" ] is false\n"
fi
if [ -n "${PBS_ENVIRONMENT}" ]; then
    printf "[ -n \"\${PBS_ENVIRONMENT}\" ] is true and value is \"${PBS_ENVIRONMENT}\"\n"
else
    printf "[ -n \"\${PBS_ENVIRONMENT}\" ] is false\n"
fi
if [ -n "${SLURM_PTY_PORT}" ]; then
    printf "[ -n \"\${SLURM_PTY_PORT}\" ] is true and value is \"${SLURM_PTY_PORT}\"\n"
else
    printf "[ -n \"\${SLURM_PTY_PORT}\" ] is false\n"
fi
if [ -n "${SLURM_JOBID}" ]; then
    printf "[ -n \"\${SLURM_JOBID}\" ] is true and value is \"${SLURM_JOBID}\"\n"
else
    printf "[ -n \"\${SLURM_JOBID}\" ] is false\n"
fi
read -t 0 line
if [ -n ${line} ] ; then
    printf "\"read -t 0 line\" is true and contains \"${line}\"\n"
else
    printf "\"read line\" is false\n"
fi