How to include shell script in C program | Unix Linux Forums | Programming

  Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

How to include shell script in C program

Programming


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-12-2006
mridula mridula is offline
Registered User
 
Join Date: Sep 2005
Last Activity: 16 January 2008, 1:13 AM EST
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
How to include shell script in C program

hi

I want to call a shell script in C program
the script is : ssh -t user@remote sh /<remote>home/user/<file_name>.sh
and other several commands

C program : Call this script and the retrive the task that is been done in <file_name>.sh file

can any one tell me how to call the script

thankx
Sponsored Links
    #2  
Old 07-12-2006
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 31 October 2014, 9:36 PM EDT
Location: Saskatchewan
Posts: 19,745
Thanks: 832
Thanked 3,375 Times in 3,162 Posts
What do you mean by 'retrieve the task'?
Sponsored Links
    #3  
Old 07-12-2006
mridula mridula is offline
Registered User
 
Join Date: Sep 2005
Last Activity: 16 January 2008, 1:13 AM EST
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
i am retriving some file that are generated by the shell script <which is running on remote machine> to my own machine from where i am executing the .c file
    #4  
Old 07-12-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
AFK
 
Join Date: Dec 2004
Last Activity: 28 July 2014, 9:39 AM EDT
Location: UK
Posts: 2,351
Thanks: 0
Thanked 6 Times in 6 Posts
So have you been able to execute the script remotely yet? You can do it via the system() call. Try something like this:

Code:
system("ssh -t user@remote sh /<remote>home/user/<file_name>.sh");
system("scp user@remote:/path/to/remote_file /path/to/local_file");

If you are being allowed to use system(), then that's all that is there to it. If not, you will have to fork and exec.
Sponsored Links
    #5  
Old 07-14-2006
bhakti bhakti is offline
Registered User
 
Join Date: Sep 2005
Last Activity: 19 September 2007, 6:48 AM EDT
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
thanks it works
Sponsored Links
    #6  
Old 07-30-2006
susheel susheel is offline
Registered User
 
Join Date: Jul 2006
Last Activity: 30 July 2006, 3:13 AM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for the info....
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to use ssh execute other shell script on other host (shell script include nohup)? orablue Shell Programming and Scripting 1 11-18-2010 08:46 PM
How to include a command in shell script? sureshcisco Shell Programming and Scripting 2 09-02-2009 05:50 PM
script/program in vi include $? or... JudoMan UNIX for Dummies Questions & Answers 5 03-18-2009 10:48 PM
How to include shell scripts in one big shell script? worchyld Shell Programming and Scripting 9 03-18-2009 12:10 PM
Include PERL script with in the unix shell script ganapati UNIX for Dummies Questions & Answers 1 04-29-2008 12:18 PM



All times are GMT -4. The time now is 09:14 AM.