GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 23, 2014 5:58 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: System Command in GTK
PostPosted: Mon Oct 15, 2012 7:23 pm 
Offline
Familiar Face

Joined: Sat Mar 03, 2012 2:45 am
Posts: 18
Hello Everyone,

When pressing a button i am opening a terminal and running a script. It will open the terminal run the script just fine. My script calls for a variable that i want to come from a gtk text field (entry). How can i get that to work? My Code is below

Code:
   gchar *os_name =  gtk_entry_get_text(GTK_ENTRY(entry_os_name));
   system("gnome-terminal -e '/home/myloginname/myprogram/src/os_step_1.sh *os_name'");


Thank You


Top
 Profile  
 
 Post subject: Re: System Command in GTK
PostPosted: Mon Oct 15, 2012 7:36 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

This has nothing to do with GTK+ in general, since concatenating strings is described in just about any C book. But just a few pointers: snprintf(), strcat(), g_strdup_printf().

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: System Command in GTK
PostPosted: Mon Oct 15, 2012 8:33 pm 
Offline
Familiar Face

Joined: Sat Mar 03, 2012 2:45 am
Posts: 18
Hello,

I found that sprintf will compile but I am getting an error "Program has been terminated receiving signal 11 (Segmentation fault)". Any Suggestions. I can't find if I left any syntax out.

Code:
   gchar *command = sprintf("gnome-terminal -e '/home/myusername/myprogram/src/os_step_1.sh %s'", gtk_entry_get_text(GTK_ENTRY(entry_os_name)));

   system(command);


Top
 Profile  
 
 Post subject: Re: System Command in GTK
PostPosted: Mon Oct 15, 2012 8:46 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

Did you even read the manual page of sprintf()? Code you have there is completely wrong.

Tadej


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group