Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Running Executable in Bash Script Post 302508344 by Duo11 on Monday 28th of March 2011 12:45:31 AM
Old 03-28-2011
Question Running Executable in Bash Script

Hey guys, so I've been trying to write a bash script called runSorter.sh that runs an executable that also takes in some parameters and outputs the results to a text file. The executable, sorter, takes in a number parameter. I want to make it so that you can input as many number parameters into runSorter.sh as you want and it will run the sorter executable for each one. So far, what I have looks like this:
Code:
#!/bin/bash                                                                      
args=("$@")
INDEX=0

if [ -z args ]; then
       echo "Error"

else
       while [ $# -gt $INDEX ]; do
              NUM=${args[$INDEX]}
              echo $NUM
              echo ./sorter $NUM
              let INDEX=INDEX+1
       done
fi

My problem is that when I run ./run-sorter.sh 100 on my terminal, it just prints this to the screen:
Code:
./sorter 100

How can I have so that it properly executes sorter and outputs everything to a text file? Thanks in advance.

Last edited by Scott; 03-28-2011 at 03:28 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Programming

Running an executable file

I've created a c program and compiled it with gcc, in unix. The file name is abc.c and it is run by typing the command ./abc I have another program which creates a child process, and I need this abc program to run on that child process. I've tried execvp(), but it doesn't work. How can I run... (2 Replies)
Discussion started by: sdsd
2 Replies

2. UNIX for Dummies Questions & Answers

Running a Script/Executable From Within a Script

Hello, I am new to Unix. I am trying to run a shell script (1node.sh) from within a Bash script that I created. I get the following error: command not foundh: line 30: 1node.sh I used Crimson Editor to make the Bash script. The weird thing is that 1node.sh will execute if I type 1node.sh... (2 Replies)
Discussion started by: modey3
2 Replies

3. Shell Programming and Scripting

How to make a script (Bash, KornShell, etc.) executable by mouse clicking?

Hello everybody, Is there any way to make a script (Bash, KornShell, etc.) executable by mouse clicking? For example you have a file myscript.sh, you run: $ chmod u+x myscript.sh Therefore it becomes executable and all you need is to run from the terminal: $./myscript.sh... (2 Replies)
Discussion started by: dariyoosh
2 Replies

4. UNIX for Dummies Questions & Answers

running command prompt executable file in shell script

hi i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script example: file name is test.vbs which contains strSoundFile = "C:\windows\Media\Notify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand... (5 Replies)
Discussion started by: atl@mav
5 Replies

5. UNIX for Dummies Questions & Answers

Problem running executable with ./

Hey all, I'm trying to execute a program and despite it appearing to be there, I keep getting this: -bash: ./aisdispatcher: No such file or directoryTo run it, I'm going into the directory where it is stored and running ./aisdispatcher...the result of which should just be a listing of options... (10 Replies)
Discussion started by: pmd006
10 Replies

6. Shell Programming and Scripting

How to produce a executable Oracle script from bash script?

Hi here's my code ${ORACLE_HOME}/bin/sqlplus /nolog <<!EOF --step 5 create db script start set feedback off set heading off set echo off conn / as sysdba spool ${ORACLE_SID}_db_link.sql SELECT 'CREATE '||DECODE(U.NAME,'PUBLIC','public ')||'DATABASE LINK '||CHR(10)... (2 Replies)
Discussion started by: jediwannabe
2 Replies

7. Shell Programming and Scripting

Running an executable from bash prompt

Hi, I'm trying to run a program from the bash prompt and I don't understand why it is returning with an error. Dig is my C program, and it takes in parameters J4, detect, 3 and 0182F98E var1="cygdrive/c/2i/test fixture/software/mccdaqtest/debug/Dig J4 detect 3 0182F98E" when I do ... (6 Replies)
Discussion started by: oahmad
6 Replies

8. Shell Programming and Scripting

How to create an executable bash script for these commands?

I wish to create an executable bash script that will run the following commands as root, that is, using sudo su iptables-save | awk '/^ / { print $1 } /^:+ / { print $1 " ACCEPT" ; } /COMMIT/ { print $0; }' | iptables-restoreMy first attempt at bash... (9 Replies)
Discussion started by: thixeqi
9 Replies

9. Shell Programming and Scripting

Making bash script allways executable when transfer ?

Does it possible to make some bash script automatic to be a executable when transfered to another pc...? (5 Replies)
Discussion started by: tomislav91
5 Replies

10. Shell Programming and Scripting

Bash script make itself executable

Is there a way to make this make itself executable? Thanks. :-) cat > somescript.sh << \EOF #!/bin/bash block_count=$(sudo tune2fs -l /dev/sda1 | awk '/^Block count:/ {print $NF}') reserved_block_count=$(sudo tune2fs -l /dev/sda1 | awk '/^Reserved block count:/ {print $NF}') perl -e... (4 Replies)
Discussion started by: drew77
4 Replies
ALTER 
INDEX(7) PostgreSQL 9.2.7 Documentation ALTER INDEX(7) NAME
ALTER_INDEX - change the definition of an index SYNOPSIS
ALTER INDEX [ IF EXISTS ] name RENAME TO new_name ALTER INDEX [ IF EXISTS ] name SET TABLESPACE tablespace_name ALTER INDEX [ IF EXISTS ] name SET ( storage_parameter = value [, ... ] ) ALTER INDEX [ IF EXISTS ] name RESET ( storage_parameter [, ... ] ) DESCRIPTION
ALTER INDEX changes the definition of an existing index. There are several subforms: IF EXISTS Do not throw an error if the index does not exist. A notice is issued in this case. RENAME The RENAME form changes the name of the index. There is no effect on the stored data. SET TABLESPACE This form changes the index's tablespace to the specified tablespace and moves the data file(s) associated with the index to the new tablespace. See also CREATE TABLESPACE (CREATE_TABLESPACE(7)). SET ( storage_parameter = value [, ... ] ) This form changes one or more index-method-specific storage parameters for the index. See CREATE INDEX (CREATE_INDEX(7)) for details on the available parameters. Note that the index contents will not be modified immediately by this command; depending on the parameter you might need to rebuild the index with REINDEX(7) to get the desired effects. RESET ( storage_parameter [, ... ] ) This form resets one or more index-method-specific storage parameters to their defaults. As with SET, a REINDEX might be needed to update the index entirely. PARAMETERS
name The name (possibly schema-qualified) of an existing index to alter. new_name The new name for the index. tablespace_name The tablespace to which the index will be moved. storage_parameter The name of an index-method-specific storage parameter. value The new value for an index-method-specific storage parameter. This might be a number or a word depending on the parameter. NOTES
These operations are also possible using ALTER TABLE (ALTER_TABLE(7)). ALTER INDEX is in fact just an alias for the forms of ALTER TABLE that apply to indexes. There was formerly an ALTER INDEX OWNER variant, but this is now ignored (with a warning). An index cannot have an owner different from its table's owner. Changing the table's owner automatically changes the index as well. Changing any part of a system catalog index is not permitted. EXAMPLES
To rename an existing index: ALTER INDEX distributors RENAME TO suppliers; To move an index to a different tablespace: ALTER INDEX distributors SET TABLESPACE fasttablespace; To change an index's fill factor (assuming that the index method supports it): ALTER INDEX distributors SET (fillfactor = 75); REINDEX INDEX distributors; COMPATIBILITY
ALTER INDEX is a PostgreSQL extension. SEE ALSO
CREATE INDEX (CREATE_INDEX(7)), REINDEX(7) PostgreSQL 9.2.7 2014-02-17 ALTER INDEX(7)
All times are GMT -4. The time now is 11:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy