Skip to main content

Executing external programs via c

import time
print time.ctime()

this snippet will print the system time.
in my networking lab, i used this python snippet to print the system time.
actually i have to write a client, server program in c to achieve this. but i
have found a lazy way.

when mam ask us to show the output i planned to run this python snippet :) (don't tell her);

only problem is i cannot make it as an executable code.

./timecli

this wont work. because only sudoers can use the chmod command to make it executable.

but gcc can make an executables.

so i planned to write a c program to run the python snippet.

#include "stdio.h"
int main()
{
  char cmd[20];
  sprintf(cmd, "python time.py");
  system(cmd);
  return 0;
}


after the compilation using gcc i got a executable to my python snippet.

happy cheating :)

Comments

Popular posts from this blog

ரிதம்பாக்ஸில் ரேடியோ மிர்ச்சி

உபுண்டு 12.04ல் bansheeயை தூக்கிவிட்டு மறுபடியும் rhythmbox default இசைப்பானாக இடம்பெற்றுள்ளது. ரிதம்பாக்ஸ்ல் bansheeயை விட பல அம்சங்கள் குறைவுதான். ஏன் banshee ஐ எடுத்தார்கள் என்று  சரியாக புரியவில்லை. என்னதான் high-bitrateல் பாடல்கள் இருந்தாலும் fm கேட்பது ஒரு மகிழ்ச்சிதான். சில வருடங்களுக்கு முன்பு எங்கள் தெருக்களில் சூரியன் fm, ரேடியோ மிர்ச்சி போன்றவை தான் என்னை எழுப்பும்.

need your response

It has been a long time... my rest hours are reduced i only sleep for 5 to 6 hours a day.. so i can't post frequently.. sorry friends.. my university is a good place to refine myself. yes..! thoughts about my programming computers are refined there.. i always wanted share my experience.. but i feared of thinking that it will helpful for you or not.. most of us don't like to hear stories of others. so i stopped blogging and of course having less time.. i have earned some good friends there... who are interested in open-source technology.. very few of us only know the linux platform.. this semester mini project also in open softwares like mysql, postgrey sql i will start blogging my experience if you are interested.. regards, Mani G

உபுண்டு டெர்மினலில் இருந்து இலவசமாக sms அனுப்பலாம்

இன்று டெர்மினலில் இருந்து எப்படி இலவசமாக sms அனுப்புவது என்று பார்க்கலாம். way2sms சென்று sms அனுப்புவதற்கு அந்த தளத்தின் விளம்பரங்களை தாண்டிதான் அனுப்ப வேண்டியிருக்கிறது. விளம்பரங்களை பார்க்கமால் சுலபமாக இந்த script ஐ பயன்படுத்தி இலவசமாக sms அனுப்பலாம். இதற்கு முதலில் way2sms ன் பயனராக இருக்க வேண்டும். இல்லை என்றால way2sms.com சென்று ஒரு அக்கவுண்டினை தொடங்கிகொள்ளவும். username, password  வேண்டும்.