First of all, thank you for trying to help. I've tried running this on 3 different computer running 3 different Linux distros with the same results. As I stated in my post, I am doing a system() call to the file that gets created.
The paths are all stated as 'system(./filea.sh)'. I've tried this with the program in different places, including a usb flash drive, using desktop icons, and clicking directly on the program icon. All scenarios produce the same results. I've tried running this in a terminal from different directories and as long as a terminal is involved in starting the program, it runs without problems.
I've created desktop icons, with full path names, including working directory. Same problem. If I run it through GDB, it works right, since I'm using a terminal to run GDB.
I'm wondering why, a terminal makes a difference. The other part of the program that uses the exact same functions to create that shell file and run it, works no matter where I start the program from.
Here's another clue. The part of the program that downloads the one file from the remote computer, immediately tries to open that downloaded file. It bombs, since that file is not actually downloaded yet. In fact, it looks like that shell file that downloads the one file doesn't even run. However, if I use the other part of the program that does work, and it downloads the file correctly, then run the part that doesn't work properly, it works, since the file is now in it's directory to work on.
Here is the code that is called from both locations. One works, the other section of the program that calls it, doesn't. The 'get_kod.sh' file never runs if called the program is started from either clicking on the program to run or started from an icon. BUT, it works if run from a terminal. In the non-working part of the program, it never reaches the openssl part of the program and never downloads anything from the remote host.
Code:
char text[250];
strcpy(text,"#!/usr/bin/expect\n");
strcat(text,"set timeout 30\n");
strcat(text,"set user [lindex $argv 0]\n");
strcat(text,"spawn scp ");
strcat(text,user);
strcat(text,"@");
strcat(text,ip);
strcat(text,":/home/");
strcat(text,user);
strcat(text,"/");
strcat(text,kod_to_get);
strcat(text," ./\n");
strcat(text,"expect \"");
strcat(text,user);
strcat(text,"@");
strcat(text,ip);
strcat(text,"'s password:\"\n");
strcat(text,"send \"");
strcat(text,pw);
strcat(text,"\\r");
strcat(text,"\"\n");
strcat(text,"interact\n");
// g_print("scp text: %s \n",text);
FILE *fptr;
// Open file for writing
if ((fptr = fopen ("get_kod.sh","w"))==NULL)
{
printf ("Cannot open file\n");
exit (1);
}
fputs(text,fptr);
if(fclose(fptr))
printf("File close error\n");
system("chmod +x get_kod.sh");
int ret;
ret = WEXITSTATUS(system("./get_kod.sh"));
// gtk_label_set_label((GtkLabel *)label_status, ret);
// Setup command to decrypt binkod file
strcpy(text,"openssl enc -aes-256-cbc -d -pass pass:");
strcat(text,ukey);
strcat(text," -in ");
strcat(text,kod_to_get);
strcat(text," -out kod.txt");
ret = WEXITSTATUS(system(text));