06-03-2010
How to enter commands to the command prompt in a program
Hey,
So I'm trying to write a program in unix to automate a process for my astrophysics research.
Basically I want the program to prompt the user for some information and store the entered string of text as a variable. I know how to do this.
This is where I need help:
Now lets say I have a command that needs to be run in the command prompt, and not in the program. How can I do that?
So for example I run the program. The program asks for the location of a certain file. The user enters the location and the program saves this text as some variable ($location).
I need the program to send the following to the command prompt: dmkeypar $location
is that doable?
---------- Post updated at 03:36 PM ---------- Previous update was at 03:18 PM ----------
Maybe if I tell you why I need to do this it will make more sense.
I have a bunch of sets of files that I want to manipulate in a similar way. Specifically I'm taking chandra satellite data files, and applying certain transformations and corrections to them. To do this I've created a recipe of the commands in UNIX I use to apply a particular transformation.
The whole recipe is about a hundred steps long. I would like to write a program so I dont have to keep entering the commands by hand, and that I only have to enter the file names or occasionally a number, which will be stored as a variable, the variable will be inserted into the recipee text, and the recipe text (with the user inputted file name) will be "entered" into the command prompt instead of back into the program.
---------- Post updated at 03:57 PM ---------- Previous update was at 03:36 PM ----------
I will be able to write my whole program easily if I can write this simple program.
When you the run the program it as you for an input.
So far the program would look like this:
#!/bin/sh
echo "Enter Location: \c"
read location
But next I want the program to input "location" into the command prompt, as if I had just opened the terminal and entered the contents of "location"
If I can achieve this I can do my whole program, since the only change will be that instead of entering merely the variable into the command prompt it enters some prescripted scripted with the variable (determined by the user input) embedded into the text.
This is all doable right?
Thanks in advance, if I can get this program to work it will save me so much time and let me actually get to the real research...
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hello,
I would like to capture the password request of a process (like passwd or smbpasswd, ...) from a C/c++ program. My idea was to use pipes, but they capture only the stdout/stdin, not the request itself (e.g. "Enter password for user tom:" is not captured by pipes).
In other words, my... (1 Reply)
Discussion started by: mousec
1 Replies
2. Shell Programming and Scripting
Hi
I have some trouble entering if-then condition in a single line on a command prompt in csh.
Could someone show how does one do that ?
eg:
source .cshrc;
cd $dir;
pwd;
test -d $backup_dir;
if
then
mkdir -p ${backup_dir};
echo inside loop;
fi;
echo outside loop;
mv -f... (3 Replies)
Discussion started by: mpc8250
3 Replies
3. Shell Programming and Scripting
I'm using rsync with the "-e ssh" option so of course it asks for a password using a prompt. Is there a way to tell a script to expect a prompt, wait for it, and give a password when it arrives?
There is a way to give rsync a password as part of its options using a file, but it only works with... (2 Replies)
Discussion started by: davidstvz
2 Replies
4. Solaris
Dear All,
I hope you can help me.
I have a pair of E2900's I've inherited. Both running Solaris 9. Both have LOM> consoles. The problem I'm experiencing only occurs when connected to the /dev/console tty. Whenever I hit 'Enter' for a new line, I receive two new lines: -
myhost# ... (11 Replies)
Discussion started by: aleith
11 Replies
5. AIX
When I use "/" to look for a particular command that I typed in the current session it says
D02:-/home/user1/temp> /job
ksh: /job: not found.
D02:-/home/user1/temp>
previously it used to fetch all the commands which had job in it..
for example subjob, endjob, joblist etc...
may I... (7 Replies)
Discussion started by: meetzap
7 Replies
6. Programming
I would like to do some of my Java programming homework at home, and when i type things such as "javac" & "java" it does not recognize it. How do i set it up so it recognizes Java coding? (1 Reply)
Discussion started by: Anna Hussie
1 Replies
7. Programming
I would like to do some of my Java programming homework at home, and when i type things such as "javac" & "java" it does not recognize it. How do i set it up so it recognizes Java coding? (1 Reply)
Discussion started by: Anna Hussie
1 Replies
8. Shell Programming and Scripting
Hello,
I am writing a script that requires the user to enter a string of numbers:
ex: 134 345 865 903
This command only allows for one variable to be entered:
set "var" = $<
and than once I got the array I want to change it to a list with each input on a different line:
... (1 Reply)
Discussion started by: smarones
1 Replies
9. Shell Programming and Scripting
Hi All
I have a script that moves files from one dir to another dir based on date, but I would like to change it in a way that whoever is going to run to enter the dates in which files will be removed. This is my script:
#!/bin/sh
touch -mt 201302250000 /tmp/ref3
touch -mt 201302282359... (14 Replies)
Discussion started by: fretagi
14 Replies
10. Shell Programming and Scripting
Hello everybody,
I am coding a script, that allow the user to enter some information using prompt messages, i.e:
sEpisode=1
read -e -i "$sEpisode" -p "Start download from episode: " downloadFrom
sEpisode="${downloadFrom:-$sEpisode}"
This code allows the user to set the download from... (4 Replies)
Discussion started by: Abu Rayane
4 Replies
LEARN ABOUT DEBIAN
glbindfragdatalocation
GLBINDFRAGDATALOCATI(3G) [FIXME: manual] GLBINDFRAGDATALOCATI(3G)
NAME
glBindFragDataLocation - bind a user-defined varying out variable to a fragment shader color number
C SPECIFICATION
void glBindFragDataLocation(GLuint program, GLuint colorNumber, const char * name);
PARAMETERS
program
The name of the program containing varying out variable whose binding to modify
colorNumber
The color number to bind the user-defined varying out variable to
name
The name of the user-defined varying out variable whose binding to modify
DESCRIPTION
glBindFragDataLocation explicitly specifies the binding of the user-defined varying out variable name to fragment shader color number
colorNumber for program program. If name was bound previously, its assigned binding is replaced with colorNumber. name must be a
null-terminated string. colorNumber must be less than GL_MAX_DRAW_BUFFERS.
The bindings specified by glBindFragDataLocation have no effect until program is next linked. Bindings may be specified at any time after
program has been created. Specifically, they may be specified before shader objects are attached to the program. Therefore, any name may be
specified in name, including a name that is never used as a varying out variable in any fragment shader object. Names beginning with gl_
are reserved by the GL.
In addition to the errors generated by glBindFragDataLocation, the program program will fail to link if:
o The number of active outputs is greater than the value GL_MAX_DRAW_BUFFERS.
o More than one varying out variable is bound to the same color number.
NOTES
Varying out varyings may have indexed locations assigned explicitly in the shader text using a location layout qualifier. If a shader
statically assigns a location to a varying out variable in the shader text, that location is used and any location assigned with
glBindFragDataLocation is ignored.
ERRORS
GL_INVALID_VALUE is generated if colorNumber is greater than or equal to GL_MAX_DRAW_BUFFERS.
GL_INVALID_OPERATION is generated if name starts with the reserved gl_ prefix.
GL_INVALID_OPERATION is generated if program is not the name of a program object.
ASSOCIATED GETS
glGetFragDataLocation() with a valid program object and the the name of a user-defined varying out variable
SEE ALSO
glCreateProgram(), glGetFragDataLocation()
COPYRIGHT
Copyright (C) 2010 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication
License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.
[FIXME: source] 05/30/2012 GLBINDFRAGDATALOCATI(3G)