Visit Our UNIX and Linux User Community


Missing print binary/executable


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Missing print binary/executable
# 1  
Old 01-31-2012
Missing print binary/executable

Hi friends,

I am trying to execute some of our scripts and apparently I had this error message:
Code:
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 structure and the binary is no where to be found. Is there a way to download just a single binary to have it available in my box once ftp-ed? Thanks!
# 2  
Old 01-31-2012
"print" is a KSH-only thing. It's not on BASH because BASH is not KSH. Use 'echo', which truly is everywhere, in binary and builtin forms.

Or printf, with its more advanced features.

Or if you don't feel like modifying your scripts that much, you could make a function at the top to replace ksh's print:

Code:
function print
{
        echo -- "$@"
}

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 01-31-2012
Quote:
Originally Posted by Corona688
"print" is a KSH-only thing. It's not on BASH because BASH is not KSH. Use 'echo', which truly is everywhere, in binary and builtin forms.

Or printf, with its more advanced features.

Or if you don't feel like modifying your scripts that much, you could make a function at the top to replace ksh's print:

Code:
function print
{
        echo -- "$@"
}

Sorry for my ignorance... previously I was using AIX and I can use print as a command inside any random script... and now I am on Linux, which uses Bash, and print will not work in this environment. is that correct?
# 4  
Old 01-31-2012
I take it in AIX, "any random script" gets you KSH? Of all the shells I've tested(ksh, ash, dash, bash, zsh, csh), only ksh and zsh have 'print'. Your scripts really are incompatible with ordinary bourne shells.
# 5  
Old 01-31-2012
Even Bourne Shell doesn't have "print".
Beware if you set forth trying to convert "print" to "printf" you need to specify the line terminator character.

Code:
# ksh
print "Hello world"
# posix
printf "Hello world\n"

Personally I prefer "echo" but the Posix police prefer "printf".


Just for interest, there is no "printf" in "ksh". Where present it is implemented as /usr/bin/printf .

Last edited by methyl; 01-31-2012 at 12:21 PM..
# 6  
Old 01-31-2012
printf has a lot more functionality, is the thing, implemented in a much more portable way. echo can be a bit of a mess. Some echo changes echo "a\nb" into a newline, some don't. Sometimes you need echo -e to do that, sometimes you don't.

But printf is nearly the same everywhere -- far less ambiguous.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #1010
Difficulty: Easy
The number 200 in base 8 equals 128 in base 10.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print Missing Header Name from File.

HI Guys, I have file A.txt ID,L1,L2,L3,L4 1A,2a,33a,44b,55c 2A,10a,14a,15b,16c File B.txt ID L1 L4 L5 Output:- ID,L1,L4,L5 (2 Replies)
Discussion started by: pareshkp
2 Replies

2. UNIX for Dummies Questions & Answers

Find the missing file and print

Hi , i will be getting 24 files for one day with a formate like 20131028_01 - 20131028_24 kind of ,i am trying to write a shell script to count the number of files and if the count is not equal to 24 print the missing files names for A in `seq 0 23`; do ls *20131024_`printf "%02d" $A`*;... (3 Replies)
Discussion started by: vikatakavi
3 Replies

3. Shell Programming and Scripting

Print a line where missing!!

Hi, I have a file whihc looks like file_1 100 200 file_2 200 300 file_4 400 500 as the file_3 is missing so I want to replace it by file_3 0 0 the final output would look like file_1 100 200 file_2 200 300 file_3 0 0 file_4 400 500 Any help is highly appreciated. Regards, (1 Reply)
Discussion started by: begin_2013
1 Replies

4. Shell Programming and Scripting

print out missing files in a sequence

Hello all, I have several directories with a sequence of files like this IM-0001-0001.dcm IM-0001-0002.dcm IM-0001-0003.dcm IM-0001-0004.dcm IM-0001-0005.dcm I would like to print out the name of the file that is missing. I currently have the following ineffecient way to do this... (4 Replies)
Discussion started by: avatar_007
4 Replies

5. Shell Programming and Scripting

convert shell script into a binary executable

Hello every one, i want to convert my shell script into a binary executable a .exe file , is it possible to do that if so are there any tools . Would the script take off when the arguments are parsed. Thanks Venu (13 Replies)
Discussion started by: venu
13 Replies

6. Red Hat

rhel6 and missing semanage binary

For the life of me, I cannot find semanage binary using a default install. I have the following packages installed. Any help is appreciated. libsemanage-2.0.43-4.el6.i686 policycoreutils-2.0.82-32.el6.i686 current kernel: 2.6.32-44.1.el6.i686 (1 Reply)
Discussion started by: twinturbos52
1 Replies

7. Shell Programming and Scripting

Perl : find perl executable binary

Hi I have an oracle perl script running as cron job across multiple unix servers. The issue is the perl binary is found in multiple directories I use in the start of the script ... #!/usr/bin/perl on some servers the script fails because /usr/bin/perl is not present. Is there a way i can... (4 Replies)
Discussion started by: PrasannaKS
4 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. Linux

missing binary operator before token "("

Hello every one, how are u doing? my macine has following os: ===================== Linux 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux here i am trying to compile a c++ project.i am getting the following error. error: ======= Generating... (4 Replies)
Discussion started by: mannam srinivas
4 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

Featured Tech Videos