Cannot Execute Binary File

hello everyone,
I created a script file (info.sh) in linux centos 6.
location of file is '/etc/init.d/info.sh'
content of file is:

#!/bin/sh
#To get the MAC address
ifconfig | grep HWaddr
#To get the HDD serial no.
hdparm -I /dev/sd? | grep 'Serial\ Number'
#To get the HDD size
hdparm -I /dev/sda |grep "device size"

gave the permission by: chmod 777 /etc/init.d/info.sh
but when i run this file by: /etc/init.d/info.sh
it gives an error like...
-bash: /etc/init.d/info: cannot execute binary file

what should i do?? Actually i have to run this file during boot up..

thanks in advance..


Similar Content



Grep Is Not Working In RHEL5.3

Hi,

I have Redhat 5.3 running on my machine. But when I am login through putty it gives me below error.
Without running any grep command I get this error on login and the grep command doesn't work.

login as: root
root@IP's password:
Last login: Mon Feb 16 15:27:55 2015 from IP
-bash: /bin/egrep: cannot execute binary file
-bash: /bin/egrep: cannot execute binary file
-bash: /bin/egrep: cannot execute binary file
-bash: /bin/grep: cannot execute binary file
-bash: /bin/grep: cannot execute binary file
[root@bkpdrill ~]# grep MemTotal /proc/meminfo
-bash: /bin/grep: cannot execute binary file

Deleted /sbin/init ... Recovered From Live CD, Still Will Not Boot?

Hi all,

Been messing around with my CentOS 6.6 VM trying to break stuff and learn with it. I thought it may be a good learning exercise to (ok, sounds a bit stupid, but purposely) delete /sbin/init to see how I could recover and learn.

I've booted into a recovery CD and recovered the /sbin/init file to my existing directory, however, I'm still having issues booting the machine.

Per Google suggestions, I have given the new init file 755 permissions but it still does not boot.

I apologize that I have not had more ideas, I am currently Googling solutions but am having a bit of trouble knowing where to start. Any suggestions would be greatly appreciated, thank you.

Why Does Grep Return "No Such File Or Directory"?

I copied the following from my linux console.

grep -lr "SMTP" *.ini
grep: *.ini: No such file or directory

I wanted to search recursively under current location in files with extenstion .ini
Actually there are files that contain "SMTP" under this directory. But I got the above error message.
What is wrong? I am using centos 6.

Thanks,
3rock

Print Column With A String Using Awk Or Grep

Hi All,

Using grep command with a defined string, you will get the row. Can I get the column instead of row? For example,

the file content is as below:

AA BB
123 456
789 ABE

execute 'grep ABE file' will give you "789 ABE". Is there any way to get the column:
BB
456
ABE
?

Thank you very much.

Why Should I Always Use Chmod When Not As A Root User

System Info:

I have normal user in CentOS 7 whose name is "mostafa" (the name of the account).

I naturally have another user called root with all privileges. User "mostafa" is put into sudoers file, too.

The OS is installed in VmWare, so the system is all mine.

Problem:

Now I create a file with touch file.sh and put a command in it, but when I want to run it with Code:
sudo ./file.sh

, an error is shown that the command Code:
./file.sh

does not exist. But if I Code:
 sudo chmod 777 ./file.sh

then it gets run. My question is that, why should I use Code:
chmod 777

when I myself have created the file, and I am in sudoers.

Can anyone explain me why shuold I still use Code:
sudo chmod 777

when the creator of the file is me.

Bash Shell Scripting Need Help Figuring Out Process For Homework - JUST WANT DIRECTIO

Ok yes this is a homework assignment BUT I am NOT looking to have the answers given to me. I am in the 6th week of my first Linux class ever and we are in our few weeks of beginning scripting. I have some ideas of what to do or where to start but not many and no one to bounce any ideas off...we are using UNIX Bash shell so any others I have no clue. The scenario is that I need a script that searches all my users home directories for bad words. I need the script to report to the screen certain info like username and word found and path. It should ask a user if it is good or bad and if bad be put into a file of list of bad file names, if good remove from list and no longer flagged by the script. What I have so far is wanting to somehow do a loop. I do know that if I do a grep -r -e kill -e steal /home/* I get a list of what I need. I also know that the list is separated by delimiters which I can pipe to get a variable for the things I need. I also know that I can put it to a file with a > filename.txt

What I have no clue is how to start a loop that would do this...

for each line in filename.txt
UNAME=...
LOC=...
TXT=...
echo "Username: $UNAME, Line with bad word found: $TXT, and Path and file name: $LOC. Is this a BAD file? (Y)"
Read YORN

if ["$YORN" = "Y" ]; then
>> (line of text from grep) badfiles.txt
fi

Next or whatever goes there...sorry if this is crazy I just really need some direction. I am trying to learn so please don't give me the answer...that will do nothing for me and I will not be able to explain the code I came up with.

Exporting Log Data To A File That Matches Stdout

hey guys,

Let's say I want to find out which log files have related ntp information in them. I use cat and grep to search through the files in /var/log and then export that to a file. this is the command...

# cat /var/log/* | grep ntp > /home/log.txt

The file created from this command will not include the directories the log entries are apart of. Why not? For example, if you do this same command without exporting to the /home/log.txt file it will show you in stdout which directory each log entry is in. Hope I'm making sense here. My question is, is there a clever way to export to a file in a way so that the file created is structured exactly like the stdout of the command below?

# cat /var/log/* | grep ntp

Need Help In Bash Scripting

I have two files which has exact same number of lines.
I want first line of first file should be filename of new file and content of this new file should be first line of second file.
Then second line of first file should be filename of again new file and content of this new file should be second line of second file.
then third line of first file should be filename of again new file and content of this new file should be third line of second file.
and so on...
I am trying to do it using for loop but I am not able to create two for loops.
This is what I have done
Code:
IFS=$'\n'
var=$(sed 's/\"http\(.*\)\/\(.*\).wav\"\,\".*/\2/g' 1797.csv) # filenames of all files
var2=$(sed 's/\"http\(.*\)\/\(.*\).wav\"\,\"\(.*\)\"$/\3/g' 1797.csv) # contents of all files
for j in $var;
do
#Here I do not know how to use $var2
done

Please help.

Reading Contents Of File

Hello all,

I am trying to figure out how to get bash to view for any contents in the "the_difference_between_today_and_yesterday.txt" file and then act if there is anything in the file. I thought i had it, but it is not working like I thought. Any ideas?

Code:
if [ -f final_version_$dater.txt ];
then
        if [ -f final_version_$yester_dater.txt ];
        then
                diff final_version_$dater.txt final_version_$yester_dater.txt | grep "^>" | sed 's/>\ //g' > the_difference_between_today_and_yesterday.txt

                        if grep ^[a-z]* "the_difference_between_today_and_yesterday.txt";
                        then
                                cp the_difference_between_today_and_yesterday.txt /tmp/24hourlemons_table; mysqlimport --user=USERNAME --password=PASSWORD --columns=name,start_date,end_date,link_url,location \
--fields-terminated-by=':' --lines-terminated-by='\n' carshows /tmp/24hourlemons_table; rm final_version_$three_days_later.txt
                        else
                                echo "There were no differences between the two files"; rm final_version_$three_days_later.txt
                        fi
        else
                echo "ERROR! The file of: final_version_$yester_dater.txt does not exist" >> error.log
        fi
fi

How I Can Print A Specific Range Of Nubers Form A File.

hello,

i am trying to make a table from some files. i used this to record how much "RD_" field i have in my file. Quote:
grep -o 'RD_' $f|grep -c 'RD_'
forexample i got 5 "RD_" fields now i want to print 5 number of fields from another file starting from 2nd field. i did it mannully like Quote:
awk 'NR==1{print"{"$2","$3","$4","$5","$6","0.0000",""0.0000""}"","}' $file
i want to make it work together and a bit auto matic like PHP Code:
awk 'NR==1{print"{"$2"to "$5"," apend zeros to make it total 7 fields"}"","}' $file 


your coments would be apreciated
thanks alot