{"record":{"id":"440b380df480dc88","repo":"alibaba/arthas","slug":"batch-file-do-not-exist-batchfile","errorCode":null,"errorMessage":"batch file do not exist: {batchFile}","messagePattern":"batch file do not exist: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/com/taobao/arthas/client/TelnetConsole.java","lineNumber":240,"sourceCode":"        CommandLine commandLine = cli.parse(Arrays.asList(args));\n\n        CLIConfigurator.inject(commandLine, telnetConsole);\n\n        if (telnetConsole.isHelp()) {\n            System.out.println(usage(cli));\n            return STATUS_OK;\n        }\n\n        // Try to read cmds\n        List<String> cmds = new ArrayList<String>();\n        if (telnetConsole.getCommand() != null) {\n            for (String c : telnetConsole.getCommand().split(\";\")) {\n                cmds.add(c.trim());\n            }\n        } else if (telnetConsole.getBatchFile() != null) {\n            File file = new File(telnetConsole.getBatchFile());\n            if (!file.exists()) {\n                throw new IllegalArgumentException(\"batch file do not exist: \" + telnetConsole.getBatchFile());\n            } else {\n                cmds.addAll(readLines(file));\n            }\n        }\n\n        final ConsoleReader consoleReader = new ConsoleReader(System.in, System.out);\n        consoleReader.setHandleUserInterrupt(true);\n        Terminal terminal = consoleReader.getTerminal();\n\n        // support catch ctrl+c event\n        terminal.disableInterruptCharacter();\n        if (terminal instanceof UnixTerminal) {\n            ((UnixTerminal) terminal).disableLitteralNextCharacter();\n        }\n\n        try {\n            int width = TerminalSupport.DEFAULT_WIDTH;\n            int height = TerminalSupport.DEFAULT_HEIGHT;","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/client/src/main/java/com/taobao/arthas/client/TelnetConsole.java#L222-L258","documentation":"TelnetConsole, when no inline --command is supplied, falls back to reading commands from a batch file (-b/--batch-file). It constructs new File(batchFile) and, if !file.exists(), throws IllegalArgumentException(\"batch file do not exist: <path>\"). The check is existence only — not readability or regular-file status.","triggerScenarios":"Invoking the Arthas telnet client with -b <path> where the path does not exist (typo, relative path resolved from unexpected CWD, file not yet created, container path not mounted).","commonSituations":"Relative batch-file path run from a different working directory; file generated by a prior pipeline step that failed; path inside a container that was not volume-mounted; permissions/ownership hiding the file.","solutions":["Confirm the batch file exists at the resolved absolute path before invoking (test -f).","Pass an absolute path to -b to remove working-directory ambiguity.","Ensure any pipeline step that generates the batch file completed successfully.","On containers, mount the host file/directory containing the batch file."],"exampleFix":"# before\njava -jar arthas-client.jar -b ./cmds.txt <host>\n\n# after\njava -jar arthas-client.jar -b \"$(pwd)/cmds.txt\" <host>\ntest -f \"$(pwd)/cmds.txt\" || { echo missing; exit 1; }","handlingStrategy":"validation","validationCode":"File f = new File(batchFile).getAbsoluteFile();\nif (!f.isFile()) {\n    throw new FileNotFoundException(\"batch file missing: \" + f);\n}","typeGuard":"static boolean batchFileReady(String path) {\n    return path != null && new File(path).isFile();\n}","tryCatchPattern":"try {\n    TelnetConsole.main(args);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"batch file do not exist\")) {\n        // fix path / generate the file, then retry\n    } else throw e;\n}","preventionTips":["Pass an absolute path to -b/--batch-file.","test -f the file in your launcher script before invoking.","Generate batch files with an explicit final step and check its exit code."],"tags":["client","telnet","filesystem","config"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}