M
M
mkone1122020-01-01 12:51:57
PowerShell
mkone112, 2020-01-01 12:51:57

How to sequentially call a utility with a set of arguments?

Often you have to sequentially call one utility with different parameters. Example:

python manage.py makemigrations && python manage.py migrate && python manage.py createsuperuser && ...

How can this be shortened in bash, cmd and powershell? Looking for something like:
python manage.py | [makemigrations, migrate, createsuperuser]

UPD: I was hoping for the possibility of a more compact notation, but we have what we have.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lesha, 2020-01-01
@mkone112

echo -n makemigrations migrate createsuperuser | xargs -n 1 -d " " python manage.py

A
alhaos, 2021-01-10
@alhaos

param(
    $process = "C:\Windows\System32\PING.EXE",
    $argsSetArray = @(
        "127.0.0.1 -n 3",
        "127.0.0.1 -n 5",
        "127.0.0.1 -n 7"
    )
)

$argsSetArray.ForEach{
    Start-Process $process -ArgumentList $_ -Wait
}

without -Wait will be parallel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question