×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Shell command and variables

Shell command and variables

Shell command and variables

(OP)
hello i'm trying to run an external file through shell (C:\>file.exe parameter) and i like let the user to input the parameter in a variable. can i pass the variable to the shell? how?

sorry for my poor english, if i'm not clear please let me know.

thanks!

jul

RE: Shell command and variables

This example passes two parameters to C:\test.bat

QB 4.5 code:

CODE

SHELL "c:\test.bat p1 p2"

test.bat:

CODE

@echo off
cls
echo In TEST.BAT
echo Parameter1 = %1
echo Parameter2 = %2
echo.
pause

Hope this helps.

RE: Shell command and variables

line input "Enter parameter for program ";Var$
shell "C:\File.EXE "+Var$
The space after exe will be mandatory. If it requires
a "/" character then
shell "C:\file.exe /"+Var$

RE: Shell command and variables

EXECUTE THE ".BAT" FILE AS SPECIFIED BY FREESTONE

THEN

In the bat file code  

SET MYPARM1=%1
SET MYPARM2=%2



THEN RUN THE PROGRAM WITH THE FOLLOWING CODE AT THE BEGINNING

MYFIRSTPARM$ = ENVIRON$("MYPARM1")
MYSECONDPARM$ = ENVIRON$("MYPARM2")

NOW THE QBASIC PROGRAM CONTAINS THE PASSED STRINGS AS MYFIRSTPARM$ & MYSECONDPARM$ .

Computer thought: I teach a lot of programming so I can learn. You can never learn it all.

RE: Shell command and variables

(OP)
thank you all!!

I did it with Buff1 advice, thank you all for your interest.

now i've got another issue,

i'm getting "illegal function call" error i guess that's because the commandstring in the SHELL is too big, is there a way to fix that?

thanks again!

RE: Shell command and variables

It would help if you could post some of the failing code.

RE: Shell command and variables

I doubt that it's too long unless it's over 256 characters.
I would more likely look to an error in the code.

Without at least a snipet though, we are unable to say for
sure. Like saying "I sneezed -- what's wrong with me?"
and expecting the exact diagnosis.

RE: Shell command and variables

Another thought: when you shell to another program/bat file the current environment is passed straight through so the values can be retrieved directly by the shelled program.

you used to be able to increase the set area in the cmd box up to 4k that you run the programs in. look in the system for that possibility, maybe use the properties folder on the cmd icon. Maybe it is in the windows equivalent of autoexec of config files . Sorry I don't have the time right now.

Computer thought: I teach a lot of programming so I can learn. You can never learn it all.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close