UBotBuddy 331 Posted April 29, 2010 Report Share Posted April 29, 2010 The Shell command works fine for me if i am executing a Batch file or command line type of program. But is there a way to pass a parameter to the program/batch file being executed. I have tried several ways but to no avail. Thanks! Buddy Quote Link to post Share on other sites
theskinnys 1 Posted April 30, 2010 Report Share Posted April 30, 2010 The Shell command works fine for me if i am executing a Batch file or command line type of program. But is there a way to pass a parameter to the program/batch file being executed. I have tried several ways but to no avail. Thanks! Buddy Just chiming in that I'm interested in knowing if you can pass variables as well. Quote Link to post Share on other sites
alcr 135 Posted April 30, 2010 Report Share Posted April 30, 2010 You mean like from the 3rd party program into UBot? That is not possible unless the 3rd party software can write information into a .txt or .csv Quote Link to post Share on other sites
UBotBuddy 331 Posted April 30, 2010 Author Report Share Posted April 30, 2010 Sorry I should have been more clear. No, I mean a parameter to a Batch file. Like: process-this.cmd myvariable Inside the batch file there would be a command like del %1.dat or copy %1.dat %.bak The %1 would be the myvariable being passed. In most Shelling environments this is possible. Having this capability allows the user to build more generic batch files that can be used in varying capacities. But then you know that already. hehehe Buddy Quote Link to post Share on other sites
UBotBuddy 331 Posted May 1, 2010 Author Report Share Posted May 1, 2010 After more testing and more deadends I am becoming more convinced that this needs to be expanded. Since uBot does not have a library of File Management function (if someone has them PLEASE share) then maybe its time some should be created. Here is what I have been trying to do. I hate having to hard code anything because I think flexibility is lost. So when I Shell to a batch file it is usually when I am trying to backup a file before re-writing to it. So if I Shell to a batch file called "rename.cmd". Then I would like to pass a parameter from a UI Text Box like a filename. So in essence my Shell command would look like Shell > rename.cmd {1} Where {1} would be my UI Text Box parameter. As it stands right now. It does not work. IF I am in a command window and I execute "rename.cmd somename" it will take the "somename" and allow me to use it within my batch file as a variable called %1. So if anyone has any ideas as how to accomplish this then I would be greatful. Buddy Quote Link to post Share on other sites
alcr 135 Posted May 1, 2010 Report Share Posted May 1, 2010 Can batch files read from .txt's? Because then you could just save the variable to a txt and let the batch read from it. But yes - this could be much more smooth in the future. Quote Link to post Share on other sites
Net66 54 Posted May 1, 2010 Report Share Posted May 1, 2010 After more testing and more deadends I am becoming more convinced that this needs to be expanded. Since uBot does not have a library of File Management function (if someone has them PLEASE share) then maybe its time some should be created. Here is what I have been trying to do. I hate having to hard code anything because I think flexibility is lost. So when I Shell to a batch file it is usually when I am trying to backup a file before re-writing to it. So if I Shell to a batch file called "rename.cmd". Then I would like to pass a parameter from a UI Text Box like a filename. So in essence my Shell command would look like Shell > rename.cmd {1} Where {1} would be my UI Text Box parameter. As it stands right now. It does not work. IF I am in a command window and I execute "rename.cmd somename" it will take the "somename" and allow me to use it within my batch file as a variable called %1. So if anyone has any ideas as how to accomplish this then I would be greatful. Buddy Could you write the batch file from within ubot with the commands and parameters in it and then use shell to execute the just written file? So basically you write out a file called temp.cmd which contains the commands "ren old.txt whatever.txt" and then "shell temp.cmd" Andy Quote Link to post Share on other sites
UBotBuddy 331 Posted May 1, 2010 Author Report Share Posted May 1, 2010 @alcr - No batch files cannot read from text files. Batch files take their input from the command line. This is a hang over from the DOS days. @Andy - Interesting. I will have to think about that. Shooting from the hip I would think that would add overhead (in terms of code size) to the overall program being developed. Maybe this would be for some projects but when File Management functions are needed then I still favor a path that can be used within uBot. For instance, $create folder$remove folder$rename file$delete file Aftr all, we have $document folder. We need more. Buddy Quote Link to post Share on other sites
The_Brit 13 Posted May 6, 2010 Report Share Posted May 6, 2010 It is possible. Here is a script that deletes a file using a batch file and a parameter shell_with_param.ubot 1 Quote Link to post Share on other sites
UBotBuddy 331 Posted May 6, 2010 Author Report Share Posted May 6, 2010 The_Brit, Thanks for the code! I never considered that kind of a layout. I tried it out but it did not work for me. The error I am getting is attached. Rather than running a delete as in your example batch file. I just setup a command like this "dir %1.* > testdirlisting.txt" I tested my batch file from a an actual shell window to ensure that it worked without errors and it did. I then ran it like you setup using your exact code and it failed. Buddy Quote Link to post Share on other sites
The_Brit 13 Posted May 6, 2010 Report Share Posted May 6, 2010 The_Brit, Thanks for the code! I never considered that kind of a layout. I tried it out but it did not work for me. The error I am getting is attached. Rather than running a delete as in your example batch file. I just setup a command like this "dir %1.* > testdirlisting.txt" I tested my batch file from a an actual shell window to ensure that it worked without errors and it did. I then ran it like you setup using your exact code and it failed. BuddyI'm not sure why you are getting that error, maybe somebody else can shed some light on it. I'll see if I can alter mine to run the commands you want to use. Quote Link to post Share on other sites
UBotBuddy 331 Posted May 6, 2010 Author Report Share Posted May 6, 2010 If it is working for you then that is great. Which makes me think that this is the right path towards resolving the issue. Buddy Quote Link to post Share on other sites
UBotBuddy 331 Posted May 6, 2010 Author Report Share Posted May 6, 2010 A VERY INTERESTING discovery! It works flawlessly when compiled but not in the UBot environment. Is this by design or ? Maybe the Masters will look at it. Thanks for your help on this The-Brit! Buddy Quote Link to post Share on other sites
The_Brit 13 Posted May 6, 2010 Report Share Posted May 6, 2010 A VERY INTERESTING discovery! It works flawlessly when compiled but not in the UBot environment. Is this by design or ? Maybe the Masters will look at it. Thanks for your help on this The-Brit! BuddyHappy to have been able to contribute after only having the product for about a week. Dave Quote Link to post Share on other sites
Kev 69 Posted November 5, 2012 Report Share Posted November 5, 2012 A VERY INTERESTING discovery! It works flawlessly when compiled but not in the UBot environment. Is this by design or ? Maybe the Masters will look at it. Thanks for your help on this The-Brit! Buddy This was very useful to know... been wondering the last hour why on Earth it woudlnt Shell and execute. Compliling makes it work... Thanks for the discovery Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.