package com.example.video_downloader.services;

import org.springframework.stereotype.Service;
import java.io.IOException;


@Service
public class ProcessService {

    public String execute(String... command) throws InterruptedException, IOException {
        ProcessBuilder builder = new ProcessBuilder(command);
//        builder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
//        builder.redirectError(ProcessBuilder.Redirect.INHERIT);
        Process process = builder.start();
        String res = new String(process.getInputStream().readAllBytes());

        int exitCode = process.waitFor();
        return res;
    }


}
