Linux / UNIX Tech Support Forum
This is a discussion on Passing value from variable while its expected from keyboard within the Shell scripting forums, part of the Development/Scripting category; I have written a small script to execute a program which is written in c++. Now the program expects input ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I have written a small script to execute a program which is written in c++. Now the program expects input from keyboard while i need to pass that from the variable. How can I do that? Pardon me..i am a beginner.
|
| Sponsored Links | ||
|
|
|
||||
|
It is possible to pass variable using standard I/O or just variable. For example:
Code:
A=”/tmp/file.txt” gedit $A Code:
#!/bin/sh echo $var > /tmp/input /path/to/c.prog < /tmp/input Let me know if you need any help
__________________
Vivek Gite Linux Evangelist |
|
|||
|
Thanks nix
i am calling a program called "cdrtool" . I cant modify this program. when I normally execute from command line $ cdrtool m12 p The 'p' is to get the input from keyboard. But i wanted to pass this value from a file. It takes the input and gives me an input. so tried like this (which was not working) #!/bin/sh ls -1 *.asc > file1 cat file1 | \ while read line do cdrtool m12 p | $line done rm file1 exit now i have changed this to as below and it works #!/bin/sh ls -1 *.asc > file1 cat file1 | \ while read line do echo $line | cdrtool m12 p done rm file1 exit Anyway thanks a lot for ur reply..i will aslo try ur method and learn how it works. Since i will be learning more in coming days, I may have questions for which i would need ur help. Thanks. |
|
||||
|
There are many ways to solve one problem. I’m glad that you sorted it out with pipes
Quote:
__________________
Vivek Gite Linux Evangelist |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SSH - Passing Unix login passwords through shell scripts | arulkumarr | Shell scripting | 4 | 27-08-2008 09:22 PM |
| passing options to a shell script | bigpaw | Shell scripting | 2 | 11-10-2007 02:40 AM |
| How do I turn off the power button on sun keyboard? | monk | Solaris/OpenSolaris | 0 | 30-01-2007 02:12 AM |
| Linux usb keyboard does not work | jerry | Linux software | 3 | 05-04-2006 09:21 PM |
| HTML variable | nathan86 | Linux software | 3 | 23-03-2005 12:29 PM |