Home >

control flow

Advertisement
  • node: Spawn processes sequentially, inheriting stdioFebruary 11

    I want to sequentially start a series of cli processes in node. I want to start the first process, wait till it exits, then start the second, and so on. The processes are cli programs so they must inherit stdio so the user can interact with each. The

  • How to do control flow in HaskellJanuary 28

    I'll give an example of what I want to do right away. version1 :: IO () version1 = if boolCheck then case maybeCheck of Nothing -> putStrLn "Error: simple maybe failed" Just v -> case eitherCheck of Left e -> putStrLn $ "Error: &qu

  • Reducing 'while loop' with conditionsJanuary 25

    My objective, in the grand scheme of things, is to print only the rows that have a similar/same field name without repetition. That, is, if three rows are duplicated, print each of them only once (rather than each pairwise comparison). A minimal data

  • If & else statement to change submit button text in _form.html.erb - Rails4January 21

    could one kindly advise me how this is written correctly: file: views/adverts/_form.html.erb <% if action: "new" %> <div class="form-actions"> <%= f.button :submit, 'Post Job' %> </div> <% else %> <div

  • Is it Legal to Use Short Circuit Operators Outside a Conditional?January 20

    The following is a questionable minimal, complete, verifiable example. This is not a question about how to improve this code. What I do want to know is whether the standard condones the use of short circuit operators outside a conditional, as is demo

  • String a command after a command that ends in & - EX: nohup log & && rm logOctober 1

    So I guess there is actually two parts to this question, because I don't want the RM to go untill the nohup command has finished, but the problem is, I love to string together commands, but my nohup command ends in &! Not sure what to do! Example des

  • How to use user input as a while loop conditionSeptember 7

    I can do this in bash: while read -n1 -r -p "choose [y]es|[n]o" do if [[ $REPLY == q ]]; then break; else #whatever fi done which works but seems a bit redundant, can i do something like this instead? while [[ `read -n1 -r -p "choose [y]es|

  • For loop for a set of variablesJuly 2

    I would like to run a for loop for a set of variables which I incorrectly denote as {A,B}. Following that my script looks like: #!/bin/sh for {A,B} in {1,2} {3,4} {5,6} {7,8} do echo A=$A B=$B C=$(($A+$B)) echo Sum,C = $C done How can I correct it? -

  • Lots of elif, is there a better way?February 4

    I have a Bash script that looks like #!/bin/bash # FECHA=`date +%j` if [ $FECHA -eq 40 ] then echo "Esta semana le toca preparar el café a Osvaldo" | mail -s 'Café' mailgroup@somedomain.mx exit elif [ $FECHA -eq 47 ] then echo "Esta semana

  • Change control flow key to scroll lockDecember 23

    So, my Scroll Lock key doesn't have much use, while I keep hitting Ctrl+S with no intention of stopping control flow. I know how to disable Ctrl+S from locking scroll (stty -ixon), but can I use Scroll Lock key instead for the same use? - UPDATE - In

  • Javascript or statment October 13

    I have a variable v in my program, and it may take any value from the set of values "a", "b", "c", ..., "z" And my goal is to execute some statement only when v is not "x", "y", or "z".

  • Press space to continueJune 4

    How do I stop a bash script until a user has pressed Space? I would like to have the question in my script Press space to continue or CTRL+C to exit and then the script should stop and wait until Space is pressed. --------------Solutions-------------

  • ssh with for loop - parentheses problemMarch 25

    I have the following script: while [ "$1" != "" ] do case "$1" in -h) HOST="$2"; shift 2;; esac done if test -z "$HOST" then [...] else TODAY=$(date +'%Y-%m-%d') configs=("/etc/inittab" "/et

  • is there a "goto" like command in kshMarch 5

    Here is my script: #!/bin/ksh #this is where I want to go again if user enter #an answer other than "yes or no" echo "yes or no?" read ans case $ans in [yY]*) echo "yes" ;; [nN]*) echo "no" ;; *) echo "yes or n

  • How to execute a Bash comand and execute two statements on failure?January 27

    Ì want to execute a Bash command, followed by two actions if and only if the test returns an error. I would prefer to solve this task as a one-liner in Bash. Here are the two forms I have tried: ssh user@1.2.3.4 "ls /home/somefile" || echo "

  • Bash: handling "[[ statement ]] || echo problem found ; exit 1" logicDecember 10

    In the statement in the title, there is a problem that even if the statement is true, it will still exit with status 1 because, as I understand it: [[ statement ]] || echo problem found ; exit 1 Evaluates to if the statement is false, echo problem fo

  • Bash to print out the make resultNovember 30

    To compile my project and to check if it's good or not, I want to print out the status message after make command. Which one should I use? make && echo "Success" || echo "Fail" make || echo "Fail" && echo &quo

  • shell script to control the number of processes of an userSeptember 18

    I have to launch a total number, NUMTOT of a program (could be any, C, Mathematica, ns-2... mathematical environments). The problem is that the computer where these processes run only admits a maximum number of executions, e.g. MAX, (MAX < NUMTOT). I

  • Shell: Break both if and for loop at onceSeptember 5

    Shell: Break both if and for loop at once. My script: ip to name resolve code IP=192.168.27.191 hostNameChecker() { if [ `getent hosts $1 | wc -l` -ne 0 ];then HOST_NAME=`hostname` DNS_IP=`getent hosts $1 | cut -d " " -f 1 | sed 's/^[ \t]*//;s/[

  • Loop through the lines of two files in parallel July 10

    The object of the script I'm making is to compare two series of files. The file names are themselves stored into two separate files, one path per line. My idea is to have two while read loops, one for each list of file names, but how can I mix the tw

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.595 s.