Run shell command step by step - vb.net

I am vb.net user.
Please some one help me!
How to run shell command in step by step.
When runing shell command in projects,the projects run all command the same time.
Cann't run step by step.
Thanks....,Sorry for Spelling.

If you're using Interaction class' Shell function, the 3rd parameter in it is boolean Wait. Set it to True - and each Shell statement will wait for completion of the command before invoking the next one.
As far as I remember, Shell doesn't wait for child subprocesses, so if you start a process which starts another one and then exits (e.g. bat file without call or with start) - you might face some issues. In this case consider changing the complete tree of calls. Another option would be to use System.Management assembly to trace cals tree using WMI as described here.

Related

Execute Unidata Process from the shell command lines?

Is it possible to execute the Unidata process from the Unix Command line??
If it's possible, can anyone please let me know how to??
I just want to add some Unidata Processes into the shell script and run it from the Unix
Cron job.
Unidata Process
Unix Command line
Yes! There are several approaches, depending on how your application is setup.
Just pipe the input to the udt process and let 'er rip
$cd /path/to/account
$echo "COUNT VOC" | udt
This will run synchronously, and you may have to also respond to any prompts your application puts up, unless it is checking to see if the session is connected to a tty. Check the LOGIN paragraph in VOC to see what runs at startup.
Same, but run async as a phantom
$cd /path/to/account
$udt PHANTOM COUNT VOC
This will return immediately, the commands will run in the background. Have to check the COMO/PH file for the output from the command. It's common for applications to skip or have a cut down startup process when run as a phantom (check for #USERTYPE)
If none of the above work because of the way your application is written, use something like expect to force the issue.
spawn udt
expect "ogin:"
send "rubbleb\r"
etc.
https://en.wikipedia.org/wiki/Expect for more info on expect

How to run DOS/CMD/Command Prompt commands from VB.NET and want to hold its terminal output for few seconds?

How to run DOS/CMD/Command Prompt commands from VB.NET and want to hold its terminal output for few seconds. After that it should be close automatically.
Depending on your goal, there could be multiple solutions to this request.
This SO post details how you can run a command from cmd.exe, passing arguments.
How to run DOS/CMD/Command Prompt commands from VB.NET?
Another idea, depending on the goal, would be to save the cmd as a batch file or similar, where you could have a pause or timed wait before the cmd window closes.
Then you could call the batch file from vb.net
I don't want to dive too deep into how each of these would be done without knowing more about the goal at hand.

Start a Spring-Shell based application not interactive

Is it possible to start a specific command of a Spring-Shell app and then return/exit the shell after the command is finished? Further is it possible to expose the exit code (System.exit) of the app to the operating system shell?
For my purpose i will take advantage of the plugin mechanism and the CLI-Annotations of Spring-Shell. But in general there is no human interaction with the app, instead a job scheduler (UC4) will start the app and check the exit code to generate an email in case of an exit code not equal to 0. On the other hand for manual tests by our customer, there is also the need of tab completion, usage help etc.
This behavior is already built-in (although we considered removing it, or at least make it optional). I see now that it is useful :)
Simply invoke the shell with your (sole) command and the shell will spin up, execute the command, and quit. Also, the return code of the shell already indicates whether there was an error or not (tried with an inexistant command for example). Of course, if your custom commands do not properly indicate an error (i.e. print an error message but perform a normal return) this will not work. You should throw an exception instead.
The behavior is back.
Run spring-shell with #my-script, like so:
java -jar my-app.jar #my-script
Where my-script is a file with your commands:
my-command1 arg1 arg2
my-command2 arg1 arg2

Execute Multiple PowerShell Files using a SSIS Package

I have multiple PowerShell script files that I need to execute in a sequential flow(one after other). Can someone please help me how to schedule multiple PowerShell files to be executed using a SSIS Package. And I need to build a fault tolerant model were I need to re-execute a powershell script in case of failure.
Running PowerShell
There isn't a built-in Execute PowerShell task (pity) so you'll need to use an Execute Process Task with the path to powershell.exe
Something that you will need to take into consideration is that the default execution policy for PowerShell is Restricted which cannot run a script. Further complicating matters is the account that runs the SSIS package will also need to have its execution policy modified to be able to fire off those scripts. It's a simple matter of Set-ExecutionPolicy RemoteSigned or whatever level you feel is appropriate but you'll need to do this from within the account.
Fault Tolerance
The simple approach is to ignore the return code in the Execute Process Task. Alternatively, if the desire is to keep running the PS1 until it doesn't fail, then you'd wrap a For Loop Container around the Execute Process Task and only set the terminal condition once the task returns a success value. Things might still go sideways depending on what the failure is.

Cancel command in Grunt that hasn't been launched

In Pig Grunt, if I make a mistake in my command (for instance not closing a '), it shows a new prompt until the command is fixed:
grunt> tmp = LOAD '/mapred/data;
>>
In the case above, adding '; would solve it, but sometimes the command is long and complex, and finding the culprit proves difficult.
Is there a way to cancel the current entry without exiting Pig altogether? I.e., not ctrl+C or ctrl+D?
Note: I know it's similar to this question how to cancel command in GRUNT shell, but in my case the command hasn't been launched yet.
Corresponding to your example, I realized one way of exiting is to complete the line which is open due to the single quote. Therefore in this case I added the following in the next line and it quit with an error.
>> ';
Not sure if there is an easier way to do this, more so because the grunt shell is still not very developed. In any case, I hope there is a better workaround for this soon.