FG

How can I launch multiple screen sessions from a single bash script?

Fresh3 days ago
Mar 15, 202625861 views
Confidence Score0%
0%

Problem

I've written a script (that doesn't work) that looks something like this: For some reason, if I copy and paste this into a terminal, it creates 7 detached screen sessions as I expect. If I run it from within a script, however, I get only the first session, "somename," when I run . Edit: If the same…

Error Output

#!/bin/sh

screen -dmS "somename" somecommand

for i in {0..5}; do
    screen -dmS "name$i" anothercommand $i
done

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I launch multiple screen sessions from a single bash script?

Low Risk

I ended up taking this question to StackOverflow, where Brian Gerard answered the question. The loop syntax is bash (3.x+) specific. By default, my system was setup to run some other shell from , so I changed my sharp-bang to and my problem was solv…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment