convert shell script into a binary executable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting convert shell script into a binary executable
# 8  
Old 12-22-2010
Well, I'm running a variety of AIX platforms. We have 4.3.3 (to be decommissioned soon, honest) one at 5.1, 32-bit and a 6.1, 64 bit. I get the same on all apart from AIX 6.1, so I put it down to user error Smilie

Unfortunately, we don't even have the gcc compiler. We do have the official IBM XLC compiler, version 5 on AIX 5.1 and version 10 on AIX 6.1 yacc appears to be on all of them too, although I've never used it. Come to think of it, I've only used the available C compiler to sompile sudo, lsof and a few other tools. Sorry about that.


So, the errors:
Code:
AIX 4.3.3/5.1
RBATTE1 @ /usr/home/RBATTE1>zcat shc-3.8.7.tar.Z |tar -xvf -
x shc-3.8.7/CHANGES, 3637 bytes, 8 media blocks.
x shc-3.8.7/Copying, 17982 bytes, 36 media blocks.
x shc-3.8.7/Makefile, 1940 bytes, 4 media blocks.
x shc-3.8.7/match, 336 bytes, 1 media blocks.
x shc-3.8.7/pru.sh, 155 bytes, 1 media blocks.
x shc-3.8.7/shc-3.8.7.c, 24962 bytes, 49 media blocks.
x shc-3.8.7/shc.1, 3136 bytes, 7 media blocks.
x shc-3.8.7/shc.README, 1544 bytes, 4 media blocks.
x shc-3.8.7/shc.c is a symbolic link to shc-3.8.7.c.
x shc-3.8.7/shc.html, 4558 bytes, 9 media blocks.
x shc-3.8.7/test.bash, 138 bytes, 1 media blocks.
x shc-3.8.7/test.csh, 52 bytes, 1 media blocks.
x shc-3.8.7/test.ksh, 142 bytes, 1 media blocks.
RBATTE1 @ /usr/home/RBATTE1>cd shc-3.8.7
RBATTE1 @ /usr/home/RBATTE1/shc-3.8.7>make
        gcc -Wall -O6  shc.c -o shc
gcc: not found

make: 1254-004 The error code from the last command is 1.


Stop.
RBATTE1 @ /usr/home/RBATTE1/shc-3.8.7>export CC=cc
RBATTE1 @ /usr/home/RBATTE1/shc-3.8.7>make        
        cc -Wall -O6  shc.c -o shc
cc: 1501-210 command option Wall contains an incorrect subargument
make: 1254-004 The error code from the last command is 40.


Stop.
RBATTE1 @ /usr/home/RBATTE1/shc-3.8.7>

Code:
AIX 6.1
$ zcat shc-3.8.7.tar.Z |tar -xvf -
x shc-3.8.7/CHANGES, 3637 bytes, 8 media blocks.
x shc-3.8.7/Copying, 17982 bytes, 36 media blocks.
x shc-3.8.7/Makefile, 1940 bytes, 4 media blocks.
x shc-3.8.7/match, 336 bytes, 1 media blocks.
x shc-3.8.7/pru.sh, 155 bytes, 1 media blocks.
x shc-3.8.7/shc-3.8.7.c, 24962 bytes, 49 media blocks.
x shc-3.8.7/shc.1, 3136 bytes, 7 media blocks.
x shc-3.8.7/shc.README, 1544 bytes, 4 media blocks.
x shc-3.8.7/shc.c is a symbolic link to shc-3.8.7.c.
x shc-3.8.7/shc.html, 4558 bytes, 9 media blocks.
x shc-3.8.7/test.bash, 138 bytes, 1 media blocks.
x shc-3.8.7/test.csh, 52 bytes, 1 media blocks.
x shc-3.8.7/test.ksh, 142 bytes, 1 media blocks.
$ cd shc-3.8.7
$ export CC=gcc
$ make
gcc -Wall -O6  shc.c -o shc
***     żDo you want to probe shc with a test script?
***     Please try...   make test
$ echo "#!/bin/ksh\necho \"Hello world.\"">robin.ksh
$ shc -x robin -f robin.ksh
$ robin.ksh.x
Killed
$



I feel completely useless on this, but extra depressed because the diskwasher popped last night (overflow/flood detection triggerred), we're snowed in and the wife's parents are with us for a weekSmilie

Any pointers? The place we really want this is on the AIX 5.1 servers, if that concentrates things.

.... on either the shc or dishwasher Smilie




Thanks,
Robin
Liverpool/Blackburn
UK

---------- Post updated at 04:09 PM ---------- Previous update was at 03:49 PM ----------

Smilie Aha! I have it working on AIX 6.1 by running Smilie
Code:
shc -T -f robin.ksh


Smilie I am a fool for not reading the other post to the end. Smilie

=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


Smilie Annoyingly, it is stil the AIX 5.1 that we really want. Smilie




Robin
# 9  
Old 12-22-2010
Oh snow, we don't see that much in Australia, especially around christmas time, in-laws - yes heaps, but snow, not so much, lol.

I think if you update the makefile and add the line is blue lines below it should compile with the CC=cc; export CC setting:

Code:
# For GNU C compiler
CFLAGS = -Wall -O6 # -pedantic
 
# For AIX 5.1
CFLAGS = -O3
 
SHELL = /bin/sh

This User Gave Thanks to Chubler_XL For This Post:
# 10  
Old 12-23-2010
Yes, yes, yes, yes, y....... no!

Code:
RBATTE1 @ /usr/home/RBATTE1/shc-3.8.7>make
        cc -O3 shc.c -o shc
    1500-036: (I) Optimization level 3 has the potential to alter the semantics of a program.  Please refer to documentation on -O3 and the STRICT option for more information.
ld: 0711-317 ERROR: Undefined symbol: .atoll
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make: 1254-004 The error code from the last command is 8.
RBATTE1 @ /usr/home/RBATTE1/shc-3.8.7>


I did try to go a bit wild when I saw the "Undefined symbol". I searched out every direcotry called lib and added it to my LIBPATH (ignoring 3rd party software)

No difference. Smilie



Robin

P.S. Let's not talk about the Cricket.

Last edited by rbatte1; 12-30-2010 at 07:38 AM.. Reason: The Ashes
# 11  
Old 01-13-2011
Quote:
Originally Posted by rbatte1
Yes, yes, yes, yes, y....... no!

Code:
RBATTE1 @ /usr/home/RBATTE1/shc-3.8.7>make
        cc -O3 shc.c -o shc
    1500-036: (I) Optimization level 3 has the potential to alter the semantics of a program.  Please refer to documentation on -O3 and the STRICT option for more information.
ld: 0711-317 ERROR: Undefined symbol: .atoll
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make: 1254-004 The error code from the last command is 8.
RBATTE1 @ /usr/home/RBATTE1/shc-3.8.7>


I did try to go a bit wild when I saw the "Undefined symbol". I searched out every direcotry called lib and added it to my LIBPATH (ignoring 3rd party software)

No difference. Smilie



Robin

P.S. Let's not talk about the Cricket.
Umm, that's a bit of a concern as atoll() is typically part of the base system (in libc.a). If your system has strtoll() we can use this instead by defining a macro below the definition of SIZE (around line 102) as show in blue:

Code:
#define SIZE 4096
#define atoll(x) strtoll(x, (char **)NULL, 10)

This User Gave Thanks to Chubler_XL For This Post:
# 12  
Old 01-17-2011
Firstly, good news that your home is not affected by the floods.


That helps a little in that I get a shc executeable, however using it fails. I created a very simple script:-
Code:
#!/bin/ksh
echo "Hello"

and ran the following:-
Code:
$ shc -x my_hello -f robin
shc -x my_hello -f robin
ld: 0711-317 ERROR: Undefined symbol: .atoll
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
shc: Error 0
$ ls -lrt | tail -5
-rw-r-----   1 RBATTE1  SYSSUP        25009 17 Jan 10:50 shc-3.8.7.c
-rwxr-xr-x   1 RBATTE1  SYSSUP        48454 17 Jan 10:50 shc
-rw-r--r--   1 RBATTE1  SYSSUP           24 17 Jan 10:53 robin
-rw-r--r--   1 RBATTE1  SYSSUP         8016 17 Jan 10:53 robin.x.o
-rw-r--r--   1 RBATTE1  SYSSUP         9514 17 Jan 10:53 robin.x.c

I also tried to edit shc.c / shc-3.8.7.c to change the two atoll references in the code to be strtoll (not even sure if this is valid! Smilie) and got the following:
Code:
shc -x my_hello -f robin
"robin.x.c", line 290.32: 1506-098 (E) Missing argument(s).
$ ls -lrt|tail -5
-rw-r--r--   1 RBATTE1  SYSSUP           24 17 Jan 10:53 robin
-rw-r-----   1 RBATTE1  SYSSUP        25013 17 Jan 10:57 shc-3.8.7.c
-rwxr-xr-x   1 RBATTE1  SYSSUP        48454 17 Jan 10:57 shc
-rw-r--r--   1 RBATTE1  SYSSUP         9231 17 Jan 10:57 robin.x.c
-rwx--x--x   1 RBATTE1  SYSSUP         7757 17 Jan 10:57 robin.x

Like a fool, I tried to see what would happen if I ran the file marked as executable:-
Code:
$ robin.x
robin.x: my_hello:  not found.
$

I did find this on an IBM site Using the GNU C/C++ compiler on AIX:-
Quote:
AIX 5.2 added support for the atoll() function, but GCC built for AIX 5.1 includes a cached copy of stdlib.h that does not include the prototype for that function.
Does this mean I've got a dead duck? Smilie We're on a mixture of AIX 5.1Smilie and 4.3.3 Smilie


Thanks again,
Robin
Liverpool/Blackburn
UK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Nice innings by Mr. Watson over the weekend. Much better these games than the all five one-sided test matches. England were lucky in my opinion not to have lost the first, and that would have changed the whole series.
# 13  
Old 01-17-2011
Good news that sprtoll() is available on your system, one more simple change to shc.c should get you going (don't forget to make it again after change):

replace:
Code:
"       if (date[0] && (atoll(date)<time(NULL)))",

with:
Code:
"       if (date[0] && (sprtoll(date,(char **)NULL,10)<time(NULL)))",

This User Gave Thanks to Chubler_XL For This Post:
# 14  
Old 01-18-2011
Eureka!

I guessed that you meant strtoll where you had sprtoll.

It works wonderfully! Ther only thing I have to do is to ensure that LIBPATH includes /usr/lib at runtime. It is a pain because some idiot (and I don't mean me for a change) has hardcoded something else in /etc/profile. That will be fun to get changed.


Anyway, many, many, many, many thanks! SmilieSmilieSmilieSmilieSmilie


Let's see what contest the cricket brings now.....Smilie

Come on the Poms! Smilie

Actually, let's just have a good game like the last one, preferably with the other result, but hey let's have fun.




Robin
Liverpool/Blackburn
UK
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

executable problems with shell script in IBM servers

We have a java stand alone application running currently on sun Solaris system. The java application runs on Jdk 1.4. We are reshooting this java application to new Ibm servers. There are 10 unix scripts for this application. All scripts works well except one shell script, This shell... (2 Replies)
Discussion started by: poojagupta
2 Replies

2. Shell Programming and Scripting

Want to convert an expect script to binary in Linux

Does anyone know how to convert an expect script to binary in linux?. (3 Replies)
Discussion started by: John Wilson
3 Replies

3. Shell Programming and Scripting

Issue while executing C executable with argument in shell script

Hi All, I am new to this forum and also shell script :) My task is I have to read CSV file get the data from the file and use the data to call c executable with data as argument.And the output from c executable should be stored to new CSV file Please find below my code testfunction() {... (14 Replies)
Discussion started by: ravjot28
14 Replies

4. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

5. Shell Programming and Scripting

Convert binary to text Perl script

Hello everyone, I have a binary file with a structure unknown. I have found 2 perl scripts that it seems to do the convertion but I get sintactic errors when I run them, may somebody test these 2 scripts please and see if really work? One if from here... (10 Replies)
Discussion started by: Ophiuchus
10 Replies

6. UNIX for Dummies Questions & Answers

Missing print binary/executable

Hi friends, I am trying to execute some of our scripts and apparently I had this error message: bash: print: command not found Every other scripts runs smoothly excepts this that uses the print command. I search the /bin and it was not there. I also tried to search in the whole folder... (5 Replies)
Discussion started by: kokoro
5 Replies

7. Shell Programming and Scripting

Is there any script which convert binary file to CSV format

Dear guys; I have a binary file and I need to convert its data to csv format ...appreciating your help. Best Regards (14 Replies)
Discussion started by: ahmad.diab
14 Replies

8. Shell Programming and Scripting

can UNIX scripting be converted into binary(executable)

hi i wanna ask that can UNIX scripts be converted into exe files?? if so, how?? and can these scripts be implemented using c++ and using their executable... ---------- Post updated at 02:33 PM ---------- Previous update was at 10:53 AM ---------- plz anybody reply.... and ya i want to... (5 Replies)
Discussion started by: umarbangash
5 Replies

9. UNIX for Dummies Questions & Answers

running command prompt executable file in shell script

hi i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script example: file name is test.vbs which contains strSoundFile = "C:\windows\Media\Notify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand... (5 Replies)
Discussion started by: atl@mav
5 Replies

10. UNIX and Linux Applications

Linking Libaries to binary executable

Hello, I am using Open Suse 10.3. I have implemented Zeroconf and the program is working with out any errors. Libray linking for normal executable: gcc -o name name.c -lavahi-client.so (WORKING) Now i have to create a binary executable, to have the program running on a device. For a... (0 Replies)
Discussion started by: bhavana
0 Replies
Login or Register to Ask a Question