Sponsored Content
Top Forums Programming Putting bash script in C program Post 302770631 by Corona688 on Sunday 17th of February 2013 04:06:30 PM
Old 02-17-2013
Quote:
Originally Posted by SkySmart
yes.
It would be better to put the data in the C part. If you make it a global array, they can be quite large. You could write it into the script's standard input with popen.

Code:
const unsigned char bytes[]={ 0x00, 0xab, ... };

int main(void)
{
        FILE *fp=popen("programname", "w");
        fwrite(bytes, 1, sizeof(bytes), fp);
}

you might want a decryption step between that and writing it of course, since people may be peeking in your file.

Quote:
i really believe this can be done.
By definition your program includes complete instructions for decrypting itself. How could you possibly hope to hide it? At best you can obfuscate it. A truly determined person will find the contents.

If you could force people to login to your sever to use it, that could be made secure. the program wouldn't need to run on their machine, they wouldn't have access to the file.

Last edited by Corona688; 02-17-2013 at 05:13 PM..
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Run Program from Bash CGI-Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This is a problem I am having with my 2 semester senior project. I have a LAMP server running Ubuntu 9.10 with... (8 Replies)
Discussion started by: JMooney5115
8 Replies

2. Shell Programming and Scripting

Problem with bash shell script program

Hi, This is my program. #!/bin/bash today=`date +"%b-%d-%Y"` SERVICE="pbxconnect.php" if ; then echo "pbx program is running" else nohup php pbxconnect.php > logpbx-$today.txt & fi On executing using "sh myprogram.sh" , i get the following error. myprogram.sh: line 4: ' My... (7 Replies)
Discussion started by: gskumar1234
7 Replies

3. Shell Programming and Scripting

bash script to check if a program is running

I'm a bit new to bash programming and I was assigned the job of writing a script that will check to see if a program server is running and to restart the program if it is not up. The script is supposed to check the program every hour (which I have looked up and I believe I know how to do) and send... (3 Replies)
Discussion started by: mcknz
3 Replies

4. UNIX for Dummies Questions & Answers

Bash script to execute a program to rename files

I just can't figure it out , so please just give me a pice of advise how to: The existing Linux program foo2bar takes as its only argument the name of a single foo file and converts it to an appropriately-named bar file. Provide a script that when executed will run foo2bar against all foo... (4 Replies)
Discussion started by: raymen
4 Replies

5. Shell Programming and Scripting

Bash script to start program and answer prompts?

I'm trying to write a script the simplifies the execution of a program: After starting the program (sh ~/.mfix/model/make_mfix) I am prompted four times for options: Do you need SMP version? (y/n) Do you need DMP version? (y/n) Do you need debug version? (y/n) Force re-compilation of... (2 Replies)
Discussion started by: lanew
2 Replies

6. Shell Programming and Scripting

Putting a separator in file using awk/bash

I have a file with the following content: a-123-345-232 a-23343-4545-545 a-67676-45454-8787 a-129-8912-9824 b-564-78678-2322 b-5454-76767-8899 b-85554-124-152-29 c-34534-654543-323 (... and so on, actually these are pretty huge records) Now, I want that the file should not be broken in to... (8 Replies)
Discussion started by: askerbis
8 Replies

7. UNIX for Dummies Questions & Answers

Running a C/C++ program and/or bash script from a server

I wish to be able to give to a client the opportunity to : 0) Turn one of my ubuntu computers into a webserver 1) See a webpage after visiting a url where an external user/client can set a couple of variables (e.g. Number1= ?, Number2=?) 2) By pressing "run" the program runs on my machine 3)... (1 Reply)
Discussion started by: frad
1 Replies

8. Shell Programming and Scripting

Help with Bash Shell Script Spell Checker program.

I have a majority of this problem done but seem to be struggling on the last couple of steps. Here is the whole problem to help you guys get a better understanding. Write a shell script that implements a simple spell checker. The filename you will use for your script will be your Z-id followed... (1 Reply)
Discussion started by: DsmRacer2k14
1 Replies

9. Programming

Program or bash script to see total progress of copy

hi all, i want a program or to make a bash script to find out the total ETA/percent (would be nice aswell a progress bar) of a copy recursive command so lets say i do - cp -r /source_folder/ /destinatation_folder/ and when i run it i get no information on the screen of how the copy is... (20 Replies)
Discussion started by: robertkwild
20 Replies

10. UNIX for Beginners Questions & Answers

Pass RegEx to java program in bash script

I can't seem to get this right. I've tried it every way imaginable using every trick I see on stackexchange and such. No luck. So nothing major here, something like: #!/bin/bash SEARCH="ARG1 ARG2 '((^EXACT$)|(.*InTheMiddle*)|(^AtBeginning*))'" java -cp /my/class/path MyClassName $SEARCH... (3 Replies)
Discussion started by: stonkers
3 Replies
explain_popen(3)					     Library Functions Manual						  explain_popen(3)

NAME
explain_popen - explain popen(3) errors SYNOPSIS
#include <libexplain/popen.h> const char *explain_popen(const char *command, const char *flags); const char *explain_errno_popen(int errnum, const char *command, const char *flags); void explain_message_popen(char *message, int message_size, const char *command, const char *flags); void explain_message_errno_popen(char *message, int message_size, int errnum, const char *command, const char *flags); DESCRIPTION
These functions may be used to obtain explanations for errors returned by the popen(3) system call. explain_popen const char *explain_popen(const char *command, const char *flags); The explain_popen function is used to obtain an explanation of an error returned by the popen(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. The errno global variable will be used to obtain the error value to be decoded. This function is intended to be used in a fashion similar to the following example: FILE *fp = popen(command, flags); if (!fp) { fprintf(stderr, "%s ", explain_popen(command, flags)); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_popen_or_die(3) function. command The original command, exactly as passed to the popen(3) system call. flags The original flags, exactly as passed to the popen(3) system call. Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. explain_errno_popen const char *explain_errno_popen(int errnum, const char *command, const char *flags); The explain_errno_popen function is used to obtain an explanation of an error returned by the popen(3) system call. The least the message will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail. This function is intended to be used in a fashion similar to the following example: FILE *fp = popen(command, flags); if (!fp) { int err = errno; fprintf(stderr, "%s ", explain_errno_popen(err, command, flags)); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_popen_or_die(3) function. errnum The error value to be decoded, usually obtained from the errno global variable just before this function is called. This is neces- sary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. command The original command, exactly as passed to the popen(3) system call. flags The original flags, exactly as passed to the popen(3) system call. Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. explain_message_popen void explain_message_popen(char *message, int message_size, const char *command, const char *flags); The explain_message_popen function may be used to obtain an explanation of an error returned by the popen(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. The errno global variable will be used to obtain the error value to be decoded. This function is intended to be used in a fashion similar to the following example: FILE *fp = popen(command, flags); if (!fp) { char message[3000]; explain_message_popen(message, sizeof(message), command, flags); fprintf(stderr, "%s ", message); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_popen_or_die(3) function. message The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. message_size The size in bytes of the location in which to store the returned message. command The original command, exactly as passed to the popen(3) system call. flags The original flags, exactly as passed to the popen(3) system call. explain_message_errno_popen void explain_message_errno_popen(char *message, int message_size, int errnum, const char *command, const char *flags); The explain_message_errno_popen function may be used to obtain an explanation of an error returned by the popen(3) system call. The least the message will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail. This function is intended to be used in a fashion similar to the following example: FILE *fp = popen(command, flags); if (!fp) { int err = errno; char message[3000]; explain_message_errno_popen(message, sizeof(message), err, command, flags); fprintf(stderr, "%s ", message); exit(EXIT_FAILURE); } The above code example is available pre-packaged as the explain_popen_or_die(3) function. message The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. message_size The size in bytes of the location in which to store the returned message. errnum The error value to be decoded, usually obtained from the errno global variable just before this function is called. This is neces- sary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. command The original command, exactly as passed to the popen(3) system call. flags The original flags, exactly as passed to the popen(3) system call. SEE ALSO
popen(3) process I/O explain_popen_or_die(3) process I/O and report errors COPYRIGHT
libexplain version 0.52 Copyright (C) 2009 Peter Miller explain_popen(3)
All times are GMT -4. The time now is 04:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy