Writing a UNIX shell script to call a C function and redirecting data to a .txt file
Hi, I am complete new to C programming and shell scripting. I just wrote a simple C code to calculate integral using trapezoid rule. I am prompting user to pass me No. of equally spaced points , N , upper and lower limit. My code looks as follows so far:
Now, I want to write a unix script which calls the program for N = 2^{i} for integers i from 1, 2, 3, ..., 20 and use the Unix redirect operator > to record this data in a file.
I am searching over internet how to pass argument through shell and even how to modify my code so that it reads that passed parameter, still no good answer. Your suggestions are highly appreciated. It will help me learn the unix shell scripting as well.
You can echo values using the shell's pipe | to hand over the arguments.
You might also have a look into argc and argv in your C code to handle passed arguments.
Please review the rules, which you agreed to when you registered, if you have not already done so.
If you did post homework in the main forums, please review the guidelines for posting homework and repost. If this is not a homework assignment, please explain how you will use this code in a real world situation.
i have written my shell script in notepad however i am struggling to pass the data file to be read to the script the data file is of .txt format. My target is to run the shell script from the terminal and pass 3 arguments e.g. polg@DESKTOP-BVPDC5C:~/CS1420/coursework$ bash valsplit.sh input.txt... (11 Replies)
I am converting shell script to Perl. In shell I have a code
parse_prog_args()
{
if
then
while
do
case $1 in
-P* | -p* )
export PROCESS_DATE=$2
export MM=`echo $2 | cut -c5-6`
export DD=`echo $2 | cut -c7-8`
export YY=`echo $2 | cut -c3-4`
export... (4 Replies)
Hi,
I need help in writing a shell script which can read data from a text file (Cancel_ID.txt) and then calls sqlplus session (Cancel.sql) with the first line parameter of the text file ("0322600453") till all rows are not completed.
... (4 Replies)
I am getting Segmentation fault at below function call in my script:
get_x() {
sqlplus -s / <<end | grep KEEP | sed 's/KEEP//;s///g'
select 'KEEP' ,table_name from all_synonyms where upper(synonym_name)= '$1';
exit
end
x=$(get_x $1)
echo " SQL OUTPUT IS :: $x"
}
I am getting output of... (1 Reply)
Ok hope my vocab is right here, i'm trying to write multiple sets of arguments to another file for example:
I have a script that accepts four arguments and sends them to a another file
$write.sh it then out in
so the file receiver.txt would contain this:
it then out in
what... (2 Replies)
Hi Experts,
can guide how we can Update a Database Table using a txt file source Using
Unix Shell Scripts.
What are the Cron Jobs codes can written to Update DB table.
txt file contains record like data.
US 09/03/2012 User DocType DocID.
these above feilds in txt files need to be updated in... (4 Replies)
Here is the following code :
1.
# gcc -c test firstprog.c
the above command will generate a executable file called "test " in which ever directory it is run.
Assuming It will also return a value.
2. In the below SCRIPT . test is a file generated by compiling a c program... (3 Replies)
Hi,
I am looking for the unix script which can takes the 2 month old data from a TXT file (there is one txt file in whiche messages are appended on daily basis) and compress them into new file.Please halp me out. (2 Replies)
i have a function written in one shell script and i want to call that function in another shell script and use the value returned by that script.
can any one suggest me how can i do that?
regards,
Rajesh.P (4 Replies)