Sponsored Content
Full Discussion: Shell Call
Top Forums Shell Programming and Scripting Shell Call Post 302519729 by jiro on Thursday 5th of May 2011 12:13:11 AM
Old 05-05-2011
Shell Call

Can someone help me figure out how to call a c program from this shell script? I want to echo a #9 option and have it call and execute a c file called dmcc.c.

Code:
#!/bin/sh
# dmc.sh
#clear
# display menu
 
while :
do
echo "1. Display date and time."
echo "2. Display what users are doing."
echo "3. Display network connections."
echo "4. Contact IT Director."
echo "5. Contact System Administrator."
echo "6. Contact Help Desk."
echo "7. Show files in current directory."
echo "8. Show calendar."
echo "x. Exit"
# get input from the user
#
read -p "Enter your choice [ 1 - 8 or "x" to Exit ] " choice
#make decision using case and esac
case $choice in
1)
echo ""
echo "Today is $(date)"
echo ""
read -p "Press [Enter] key to continue..." readEnterKey
;;
2)
echo ""
echo "Current network connections are"
w
echo ""
read -p "Press [Enter] key to continue..." readEnterKey
;;
3)
echo ""
netstat -nat
echo ""
read -p "Press [Enter] key to continue..." readEnterKey
;;
4)
echo ""
dl0101="Doris Long"
dltele="921-555-0101"
echo "IT Director: $dl0101 phone: $dltele"
echo ""
read -p "Press [Enter] key to continue..." readEnterKey
;;
5)
echo ""
mf0202="Mark Filgo"
mftele="972-555-0202"
echo "System Director: $mf0202 phone: $mftele"
echo ""
read -p "Press [Enter] key to continue..." readEnterKey
;;
6)
echo ""
cp0303="Casandra Pitts"
cptele="972-555-5555"
echo "Help Desk Administrator: $cp0303 phone: $cptele"
echo ""
read -p "Press [Enter] key to continue..." readEnterKey
;;
7)
echo ""
echo "List files in PWD"; ls -l;
echo ""
read -p "Press [Enter] key to continue..." readEnterKey
;;
8)
echo ""
cal ;
echo ""
read -p "Press [Enter] key to continue..." readEnterKey
ME=/home/cp0198/
;;
9)
/path/to/c_prog arg1 arg2
x)
echo ""
echo "Bye!"
echo ""
exit 0
;;
*)
echo ""
echo "Error: Invalid option..."
echo ""
read -p "Press [Enter] key to continue..." readEnterKey
;;
esac
echo "My our directory is $HOME."
echo "This is our current path: $PATH."
echo "This is our current server name is $HOSTNAME."
echo "This is our current operating system is $OSTYPE."
echo "The current user is $USER."
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Call Telnet From Within A Shell?

Hi there, I got a big problem. For one of our customers I did a website (php) that connects to another machine "A" (server) to machine "B" via expect. Now he wants that after the the connection with "B" is established, a telnet connection to "C" is opened, and some commands are executed.... (2 Replies)
Discussion started by: Tubbietoeter
2 Replies

2. Shell Programming and Scripting

Shell script call from a DB trigger

Has anybody been able to execute a shell script call from a database trigger? If so what are the steps to execute it? Do we have any specific packages in Oracle? Reards, Rahul. (1 Reply)
Discussion started by: rahulrathod
1 Replies

3. Shell Programming and Scripting

How to call Java by using shell script

Hi All, I am new to shell script, just wanted you guy to help. How do i call a java program by using shell script, pls give some samle code for it, thank you ver much. (2 Replies)
Discussion started by: aaabbb123123
2 Replies

4. Shell Programming and Scripting

Need to call an Executable (.exe) using shell

Hi all , I need to call an executable (.exe) using shell script. Actual need is i need to call that shell script and do an export of some tables is there any way . the executable is datamover Please let me know if there are any option !! (2 Replies)
Discussion started by: raghav1982
2 Replies

5. UNIX for Advanced & Expert Users

What do you call the > thingy in context of the shell?

I can't for the life of me remember what the name is for ">" My mentor told it to me 20 years ago and I can't remember it now. I know we like to call it re-direct, but there was a name othere than that he used. During a recent training session, someone cut and paste from a file that just happened... (8 Replies)
Discussion started by: theninja
8 Replies

6. Shell Programming and Scripting

how can i call one korn shell from a shell

Hi guys, please help me I have a ksh script (second picture down), in that script I define the function DATECALC. Now I want to use this function KSH in a program shell. How can I call this ksh from my shell program? My shell program is... in the first two lines I tried to call... (1 Reply)
Discussion started by: acevallo
1 Replies

7. Shell Programming and Scripting

Call web service from Shell

Hello All, I have to import data from xml file to mysql database multi-time a day. I think it is better to write a tool to help this. So I write a web service in php. I don't know that if we can call a web service via shell script. If it can, I think we can create a cron job to help run it... (2 Replies)
Discussion started by: hapytran
2 Replies

8. Red Hat

how to call a particular function from one shell another shell script

please help me in this script shell script :1 *********** >cat file1.sh #!/bin/bash echo "this is first file" function var() { a=10 b=11 } function var_1() { c=12 d=13 (2 Replies)
Discussion started by: ponmuthu
2 Replies

9. Shell Programming and Scripting

Call makefile from shell script

I'm writing a VERY simple shell script. I need to call a makefile in a subdirectory. What's the command I need to use? ./dir/make and ./dir/makefile doesn't work. Thanks in advance (1 Reply)
Discussion started by: yamahabob
1 Replies

10. Shell Programming and Scripting

How to call a function in Shell..?

#!/bin/bash FUN_ECHO(){ echo $1 } FUN_ECHO "hi how are you ?" This code will work fine. BUT is it possible to make the following to work ? FUN_ECHO "hi how are you ?" FUN_ECHO(){ echo $1 } I know that the code will be executed line by line. But i have a number of... (5 Replies)
Discussion started by: linuxadmin
5 Replies
MSSQL_FIELD_SEEK(3)													       MSSQL_FIELD_SEEK(3)

mssql_field_seek - Seeks to the specified field offset

SYNOPSIS
bool mssql_field_seek (resource $result, int $field_offset) DESCRIPTION
Seeks to the specified field offset. If the next call to mssql_fetch_field(3) won't include a field offset, this field would be returned. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). o $field_offset - The field offset, starts at 0. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Using mssql_field_seek(3) on the example for mssql_fetch_field(3) <?php // Connect to MSSQL and select the database mssql_connect('MANGOSQLEXPRESS', 'sa', 'phpfi'); mssql_select_db('php'); // Send a select query to MSSQL $query = mssql_query('SELECT * FROM [php].[dbo].[persons]'); // Construct table echo '<h3>Table structure for 'persons'</h3>'; echo '<table border="1">'; // Table header echo '<thead>'; echo '<tr>'; echo '<td>Field name</td>'; echo '<td>Data type</td>'; echo '<td>Max length</td>'; echo '</tr>'; echo '</thead>'; // Dump all fields echo '<tbody>'; for ($i = 0; $i < mssql_num_fields($query); ++$i) { // Fetch the field information, notice the // field_offset parameter is not set. See // the mssql_field_seek call below $field = mssql_fetch_field($query); // Print the row echo '<tr>'; echo '<td>' . $field->name . '</td>'; echo '<td>' . strtoupper($field->type) . '</td>'; echo '<td>' . $field->max_length . '</td>'; echo '</tr>'; // Move the internal seek pointer to the next // row in the result set mssql_field_seek($query, $i + 1); } echo '</tbody>'; echo '</table>'; // Free the query result mssql_free_result($query); ?> SEE ALSO
mssql_fetch_field(3). PHP Documentation Group MSSQL_FIELD_SEEK(3)
All times are GMT -4. The time now is 05:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy