bash scripting problem
hey there
i was trying to execute a c program using a bash shell script script was as follows #!/bin/bash `gcc shiv.c -o shiv` `chmod 777 shiv` `./shiv` this was displaying an error that enter command not found.(ENTER is written in the first printf command in shiv.c file. then i tried #!/bin/bash echo `gcc shiv.c -o shiv` echo `chmod 777 shiv` echo `./shiv` then the problem was that i had to enter all the inputs first then the output was coming. e.g in my c program main() { int a; printf("enter the no of persons"); scanf("%d",&a); } when i executed the script written three commands as mentioned above the scanf statement was running before printf; kindly help me.. |
Quote:
Code:
#!/bin/bash |
You don't need the back-ticks, try this:
Code:
#!/bin/bash |
Quote:
echo is itself a "command" and then you are using backticks under it for chmod too, that is never required. give some time to read google pages and get the correct use of commands before actually using them in scripts. |
All times are GMT -5. The time now is 07:17 AM. |