0

Ok, so I have this batch script and what I want to happen is that when you run the script it does some standard stuff like change the path and access files etc... but after it's done that it goes back to being a normal cmd prompt/terminal where I can type in commands at free will.

Can this be done (in either dos or bash)? Is there like an execute command that I can put in an internal while loop or is there a command where when the scirpt ends it can go back to the normal cmd/terminal?

3 Answers 3

1

Do you need a full bash prompt? Or would something like this be enough?

#!/bin/bash
echo -n "Enter cmd: "
read COMMAND
echo ${COMMAND} | bash

Also, in a script, you can just execute bash and get a full prompt in the current environment.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah, that's epic, thanks. I has hoping for a proper prompt, but that fine too. Do you by any chance know how I can do the something equal or similar in a dos prompt?
1

In Dos / windows command prompt if you run the batch file from command line you will get the prompt back always by default. Just like running any other command in command prompt. Also in windows when the batch file execution is complete you can just put Cmd.exe when everything has finished running I.e at the end of the batch file. Hope this helps! E.g

@echo off
Echo running
.
.
.
Cmd.exe

Or even at the end

Echo %command% | Cmd.exe

3 Comments

Ahhhhh, so close. the Echo %command% | Cmd.exe is what I need, but I need to change the PATH as part of the top of my script so I get a Cmd.exe is not a recognized file or command
Sorry dont understand that fully, Am I correct in understanding that you need Cmd.exe to be disabled in a way after your batch file finishes running ?
Don't worry about it. I got my self figures out. Thanks for your help though :)
0

Never mind, I got a good solution using this code: (for windows)

set /p command=CMD: 
%command%

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.