Programming C on Linux

This is a discussion on Programming C on Linux within the C Programming forums, part of the General Programming Boards category; Hi, Iam writing a C program, which should use "ssh" to login to another computer execute some steps and logout ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    4

    Question Programming C on Linux

    Hi,
    Iam writing a C program, which should use "ssh" to login to another computer execute some steps and logout and come back to my own computer.

    if I use system command eg system ("ssh IP");
    iam able to go to different PC but iam not able to come out as all further system commands dont execute .

    Is their any way I can do it ?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    That's because
    Code:
    system(yourcommandhere)
    is essentially consisting of:
    Code:
    if (fork())
       exec("yourcommandhere");
    else
       wait();
    So until "yourcommand here" stops, the current thread is held waiting for the process to finish.

    There are various ways to achieve what you want. One way would be to generate a script-file, copy it to the other machine using scp, and then run the script file on the other machine. This can probably be done in a shell-script rather than using C, but if for whatever reason you feel that C is more appropriate, then it can be done in C too.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 11:40 AM
  2. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 11:03 AM
  3. Dabbling with Linux.
    By Hunter2 in forum Tech Board
    Replies: 21
    Last Post: 04-21-2005, 04:17 PM
  4. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 04:15 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21