Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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..
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..
First, it should not be mode 777. At most it could be 755. Having world write access would allow anyone to change the file... and be able to gain root access when it is run by root - at boot time or any other time.
Next, for it to be run at boot time, you might check the security labels of other scripts... If the script doesn't have the proper label it can't be executed.
this changes in CenOS 7, I believe the security label changes to help isolate boot utilties from introducing security failures (which would be caused by having world write access).
Okay 755 chmod
Boot up is 2nd or final stage
Firstly I have to run manually..
And its givin me same error even manually
Is there any code error? Or syntax and all...
---------- Post added 04-09-15 at 12:05 PM ----------
Okay 755 chmod
Boot up is 2nd or final stage
Firstly I have to run manually..
And its givin me same error even manually
Is there any code error? Or syntax and all...
Okay 755 chmod
Boot up is 2nd or final stage
Firstly I have to run manually..
And its givin me same error even manually
Is there any code error? Or syntax and all...
It should run fine interactively. If not, you can use the "-vx" option to turn on verbose messages.
The only executable (to start with) is /bin/sh, so that has to exist. One thing - depending on the location of the shell script: If it is a partition mounted with noexec, then you would get the error message you are getting.
I don't have a handy CentOS 6 system, but it should be linked to /bin/bash.
The other commands could be a problem if the PATH environment is not what the script expects, but that depends on WHEN it gets executed. A script like this would be running from rc.local.
NOTE: output to stdout will not be visible as the console terminals are not set up. Redirections to /dev/console should go to what is currently the console (and show in logs), but may also not be visible (depends on version - I think there is/will be a problem with CentOS 7, but I don't have it running at the moment either).
Centos 6,
i want to make a script file to read MAC address and hdd no. and size, which should be run during boot up of the linux machine.
thats y i put the file in '/etc/rc.d/init.d/info.sh' file name is 'info.sh'
i did chmod +x /etc/rc.d/init.d/info.sh
chmod 755 /etc/rc.d/init.d/info.sh
just for testing to make sure that it's working properly or givin perfect output, i want to run it manually...
after that i will check at the time of booting.
all commands of info.sh file is working perfectly.. no doubt because each and every command i checked manually by typing in linux terminal..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.