General :: Shell Script Statements In Init?

May 21, 2010

I have made some modifications to the init script that runs when my PC boots to take me to a /bin/sh shell so I can run some custom scripts. When I exit from here the init statement should mount the root file system and switch_root to it. This all works correctly however the same init statement will be run on two types of pc's and the address of the root fs is different between them. On one PC it sits on /dev/sda1 and on the other /dev/hda1. To select the appropriate addresses I used dmesg to find out if it was the i5 PC and if/else statements to select the right hard drive location.

When I try use a if/else statement in the init script it ends up preforming both the if and the else code. Is there any reason the if else statements wouldn't work the exact same in the init script (it's all shell scripts isn't it?

[Code]...

View 3 Replies


ADVERTISEMENT

General :: Looping Through A Shell Script With Sql Statements?

Oct 7, 2009

I'm working on the Solaris environment and the DB i'm using is Oracle 10g. Skeleton of what I'm attempting; Write a ksh script to perform the following. I have no idea how to include my sql query within a shell script and loop through the statements. Have therefore given a jist of what I'm attempting, below.

1. Copy file to be processed (one file at a time, from a list of 10 files in the folder ).

Code:

for i in *
do
cp $i /home/temp

2 . Create a snapshot(n) table : Initialize n = 1

Code:

create table test insert account_no, balance from records_all; -- creates my snapshot table and inserts records in SQL

3. Checking if the table has been created successfully:

Code:

select count(*) from snapshot1 -- query out the number of records in the table -- always fixed, say at 400000

Code:

if( select count(*) from snapshot(n) = 400000 )
echo " table creation successful.. proceed to the next step "
else
echo " problem creating table, exiting the script .. "

4. If table creation is successful,

Code:

echo " select max(value) from results_all " -- printing the max value to console

[code]....

View 7 Replies View Related

General :: Case Statements In Bash Scripts

Sep 4, 2010

while learning to write bash scripts, i decided to write some script that, given an integer as input, will tell you the square root of that integer (provided the integer in question is a perfect square). i have already done on using primarily if statements and a while loop. i decided that using a case statement would be a lot simpler and i would be able to make the script more functional. here is what i have so far

[Code]....

i have tried all posible combos of using -ge or >= but i get pretty much the same thing.
the idea is, for now, if the input is greater than or equal to 0 that it will echo test. can you do this sort of thing with case statements? or will it only work if i give it specific values like [1-9] (if this is the case then i dont think the case statement will work for what i want to do)

View 4 Replies View Related

General :: Bash Scripts - Comparing Multiple Items Or Conditions Using 'if' Statements?

Mar 12, 2011

comparing multiple items or conditions using 'if' statements? I want to do something if one or more conditions is true, for example:

If a = 1 or b = 1.

I've tried:

[Code]...

View 5 Replies View Related

General :: Kernel Panic - Not Syncing - No Init Found - Try Passing Init - Option To Kernel

Apr 19, 2011

Im am building a Linux distro. It will be very tiny and fast.

I only have a minimal linuxkernel (bzImage) who is 1,2 mb big. And then I have Busybox who is 174,6 kb big.

The commands in busybox is: cd, ls, mkdir, rmdir, wget, httpd, clear, rm, poweroff, halt, reboot, fdisk, mount, umount, free, and cp.

When I compiled the kernel i use initramfs/initrd function and point it to a folder where initrd/initramfs source is.

The kernel works OK with others initramfs/initrd files. But not with my own.

Quote:

Here is how the end of the kernelcomplie look like.

Quote:

Here is my init file who is the initrd/initramfs source.

Quote:

The initramfs folder contains "bin" (folder) and "init" a file. No more.

The problem is that the kernel cannot find/read init file.

View 4 Replies View Related

Ubuntu :: Using Variables In Awk IF Statements?

Nov 2, 2010

I have a list of names (testnames.txt) and I have a set of log files (testlogdata.log). I'm trying to search the column in my log file for each of the names in my testnames.txt file, and output the result to individual files, name1.txt, name2.txt, name3.txt, etc the names in the column of my log file can appear in different formats , ie the name "Tom Smith" can appear as "tom_smith", "tom-smith", "ACME/tom.smith", "ACME/thomas.smith". etc. To allow for the variations, I have my names in the testnames.txt as expressions, ie, for tom smith, I use the expression "to.*smith", etc.I'm running the following command:

for i in $(cat testnames.txt); do awk '{if ($9~/$i/) print $0}' testlogdata.log > $ioutput.log; done

I want the command to read a value for i, insert it into the if ($9~/inserted value for i/, and dump each line from testlogdata.log into a file named <value-for-i>output.log.

View 4 Replies View Related

Ubuntu :: Script Driving Nuts With If Statements?

Oct 21, 2010

I for the life of me is having a hard time with some scripting in Dash with branching statements. What the heck? I read many tutorials all over the net and none of the codes work. They suggest all sorts of variations, but it ain't working for me. Can anyone tell me why the code below always return "Y"?

Code:
#!/bin/sh
clear
echo -n "---> Enter Y or N? "
read answer
if [ "$answer"="Y" ] ; then

[Code]...

Perhaps someone can give me a short explanation on how if statements work? So far my linux experience has been nothing, but a frustrating mess.

View 4 Replies View Related

Ubuntu :: Computer Seemed To Be Frozen - Reboot - No Init Found. Try Passing Init - Bootarg"

Jan 1, 2011

I've been dual booting 10.10 with Windows7 for about a month. Today is the first time I've encountered a serious problem.

This morning, nothing functioned properly after trying to open several programs. The computer seemed to be "frozen", although the mouse was working fine.

I decided to reboot, but then encountered an even bigger problem.

It failed to boot and got this message: no init found. try passing init= bootarg

The problem now is that it requires a Live CD session and I keep getting this: GLib-WARNING **: getpwuid_r(): failed due to unknown user id (0)

In case it matters, I didn't install 10.10 from an ISO, I just upgraded from 10.04.

View 2 Replies View Related

Ubuntu :: Error - No Init Found - Try Passing Init=bootarg

Jan 20, 2010

Ubuntu 9.10 will not boot! System froze this morning, I restarted and it is now failing to boot. Starts loading grub and I get this message:

mount: mounting /dev/disk/by-uuid/04aa3697-7bc0-45b5-b86a-77a1e6534bd5 on /root failed: invalid argument
mount: mounting /sys on /root/sys failed: no such file or directory
mount: mounting /dev on /root/sys failed: no such file or directory

[code]....

I booted with 9.04 LiveCD discovered the drive could not be mounted-ran fsck -ln and it told me the drive has no valid partition table. I have had intermittent problems mounting flash drives before this, so I'm kind of worried it might be a hardware issue.Also have files on that drive I would rather not lose, so reinstalling is hopefully a last resort.

View 9 Replies View Related

Programming :: Cannot Get Conditional Statements To Work In XDialog/Dialog

Feb 5, 2011

I cannot seem to get if else statements to work. if $choice == Dog then i want it to say "you selected Dog" The variable choice has the value Dog in it as proved at the end by echo "yes $choice is $choice" following the error Code: ./test.sh: 37: [$choice: not found How do i get the conditional statement to work? What's wrong here? This is the full script:

Code:

#! /bin/sh
: ${DIALOG=dialog}
: ${DIALOG_OK=0}

[code]....

View 7 Replies View Related

Programming :: If Statements With Decimal Places - Compare It To A Predefined Value

Aug 11, 2010

I'm writing an if statement where a variable is a number such as 14.05 (this is actually a temperature) and I want to compare it to a predefined value, sample code below:

Code:

I have all sorts of errors regardless of how I do this (double quotes, square brackets). The best idea I've had is stripping off the decimal place so it's a 4 digit number (e.g warning=1503 and DEV_TMP=1405) however this seems a little unnescessary and I'm sure there's an easier way of achieving the same thing.

View 11 Replies View Related

Programming :: SQLite Read, Write, Select, Compare Statements For C++

Jun 9, 2010

I am using C++ with SQLite db in a program that will read read a sub set of records, compare records and write different records to another database. I have a SQLite book, but it only shows examples for the C API. Anyone have code samples in C++ for the following:

Open database
Close
Select *
Read
Write

Or, just show me how to execute a SQL statement with C++ and I can then figure out the various SQL statements I need.

View 5 Replies View Related

Server :: Diffrence /etc/init.d And /etc/init.d/rc.d Scripts?

Jul 29, 2010

me the difference between /etc/init.d scripts and /etc/init.d/rc?.d scripts.

View 3 Replies View Related

General :: $HOME/.bashrc Disabled When User Shell Is 'rbash' (restricted Shell)?

Jun 15, 2011

MACHINE: HP Proliant DL260G5OS: SLES 11 SP1kernel: Linux xserver 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64 x86_64 x86_64 GNU/LinuxIt is used as remote xserver in a LAN.I have configured /usr/lib/restricted/bin/.rbashrc with some environment variables but when the users logon in the system finally is executed $HOME/.bashrc and some environment vars are overwritten.

View 2 Replies View Related

Programming :: Init Scripts In /etc/init.d?

Sep 17, 2010

I have written an init script and placed it in /etc/init.d/ directory.What I would like to know is, will the script run automatically or we need to install the script using "install_initd" command.If I have to invoke this command manullay, what will be the best place to do this ? Can I add this to "/etc/init.d/rcS" file

View 6 Replies View Related

Debian :: INIT : Cannot Execute /etc/init.d/rc?

May 7, 2011

I'm trying to boot Emdebian lenny on my compact flash and it shows the following errors during boot time :

Code:
Mounting local filesystems ... done .
/etc/rc.d/S35mountall.sh : line 45 : uname : command not found .

[code]...

View 3 Replies View Related

Software :: Stuck In Init 3 Although Indicates Its Init 5?

Mar 17, 2011

openSUSE 10.3 on Itronix IX260+ Stuck on command line, init 3, and all attempts at graphic init 5 fail. Get these messages:(EE) No devices detected; Fatal screen error: no screens found; AIGLX disabled Primary Device is PCI 01:00:0kernel:device-mapper:multipath round-robin:version 1.0.0 loaderkernel:device-mapper:table:253:0:multipath: error getting device
kernel:device-mapper:ioctl: error adding target to tableProblem would seem to be with the device-mapper, but have no idea how to fix it.

View 3 Replies View Related

Ubuntu :: Wont Boot - "no Init Found. Try Passing Init=bootarg"

Jan 31, 2011

While I was using my computer a few days ago, the terminal stopped working properly, so I tried to reboot, and when it started up again it wouldn't boot and said "no init found. try passing init=bootarg"

This has happened twice before, so I really need to figure out what keeps happening, otherwise I can't continue to use linux. i reinstalled both times before. i think that this is caused by a process that prevents me from using the hard drive, because when I try to check the disk in the terminal or in gparted, it says Device or resource busy while trying to open /dev/sda1. Filesystem mounted or opened exclusively by another program?

Also, in the disk utility, in the lower right corner of the filesystem it has a spinning "loading wheel".(i'm not sure if that means anything)

I am using ubuntu 10.10, but am not sure what kernel I am using, but i tried a few different kernel options(there's three of them at start up). safe mode does not work either.

View 3 Replies View Related

General :: Write A Shell Script Instead Of Shell Function?

Apr 27, 2011

I would like know when it is necessary or advisable to write a shell script instead of shell function ?

View 3 Replies View Related

General :: Open A New Shell From A Shell And Switch Between Them?

Jan 18, 2011

I am wondering if I can open a shell or new terminal thing from within the terminal in a unix/linux enviroment. Particularly a commandline only one where there is no GUI. Is this doable? how do I do it?

View 3 Replies View Related

General :: Shutdown A Box Without Running Init 0?

Sep 30, 2010

I want to shutdown my computer as if power was cut off (don't ask me why). How do I do this under Linux?

View 6 Replies View Related

General :: Difference Between StartX And Init 5?

Aug 11, 2011

When I run the command startx it launches me immediately into Gnome without having to login and if I attempt to go back to the command line interface by typing in the comamnd init 3 in the x-terminal it does nothing. If I attempt to hit CTRL-ALT-Backspace it does nothing however if I were to run init 5 it launches me into the Gnome Display Manager and expects me to login and if I run init 3 in the x-terminal it shutdowns the x-server and returns me to the command line interface.

View 3 Replies View Related

General :: Difference Between Init 0 And Shutdown -h Now?

Mar 28, 2010

see if there are differences between init 0 and shutdown -h now?

View 3 Replies View Related

General :: Add Routes Before Init Scripts?

Aug 11, 2010

Our system has a large number of init scripts (over 180). When we reboot it, we need it to be reachable over the network before all the init scripts load, so putting the routes in rc.local does not work. What's the best place to put the routes so that they get added as soon as possibe?

View 4 Replies View Related

General :: Working Of Init Command ?

Dec 14, 2009

I would like to know the working of init command.please tell discribe the init script stored in vim /etc/rc.d/init.d/functions. what happen when init changes its run level.

View 2 Replies View Related

General :: Kill XServer (Init 3 / 5 Does Not Work)

Feb 23, 2011

I'm running Linux Mint 10, although I've had this same issue with other variants of Linux. I've been told/found while researching that if the X server hangs or otherwise errors, one can drop to a root prompt, usually at another tty, and execute init 3 (to drop to single user mode) and then init 5 to return to the default, graphical session. Needless to say, I've tried this before in multiple configurations on multiple machines to no avail.

The only feedback I receive form executing those two commands is a listing of VMWare services (from a kernel module) that are stopped and then restarted. If I run startx (either before or after init 3), then I am told that the xserver is still running and that I should remove /tmp/.X0-lock. Having tried that, it removes that error message, but claims that the xserver cannot be attached as another instance is running. How do I kill the xserver completely? Can I killall some process name?

View 2 Replies View Related

General :: Init Script Approx 30 Sec To Stop?

May 6, 2011

Actually I used a skeleton init script provided in /etc/init.d/ and did some edits to run my own daemon process. This is my source code of file

#! /bin/sh
### BEGIN INIT INFO
# Provides: statd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5

[Code]...

Where is a mistake and this script also not printing a "starting [DAEMON]" or "stop [DAEMON]" when I executed the command sudo service [daemon] start/stop

View 1 Replies View Related

General :: Accessing To A Usb Stick While Booting With Init=/bin/sh?

Mar 28, 2011

I am trying something: I would like to access to some data stored on a usb stick while I am booting to the kernel using the "init=/bin/sh" parameters.Is that possible ?My USB stick is detected when I do 'cat /var/log/messages.log | grep sdb". I had to "modprobe usb-storage".Quote:localhot kernel : sdb: sdb1localhost kernel: sd 3:0:0:0: [sdb] Attached SCSI removable diskBut I still can't get it mounted.Quote:mount: special device /dev/sdb1 does not exist"

View 2 Replies View Related

General :: Init.d Process Does Not Return To Prompt?

Jul 9, 2010

I have a script in /etc/rc.d/init.d named foo. I want to start/stop/restart my process as follows:$ foo start But I do not see the [OK] message once it starts. There is no shell prompt returned either. It seems that my own process is the problem. The executable that foo calls is built from this sample code:

int main()
{
do {
printf("Hello world
");
sleep(1);
} while (1);
}

Do I have to return some kind of signal handle for this to work?

View 6 Replies View Related

General :: Initramfs - Attempted To Kill Init ?

Nov 10, 2010

For a special purpose I needed a initramfs - that didn't work. So I reduced the initramfs setup to the simplest.

Mount the root and switch_root into it. But that didn't work either.

If I go with the init-script for the initramfs I posted below the system prints out the switch_root usage-text from busybox. But the syntax is right, ain't it?

When I use chroot instead of switch_root then it prints the usage-text of init before the kernel panic.

If I try with "/sbin/init 5" then, after a while the system reports "init: timeout opening/writing control channel /dev/initctl".

In the other cases I get the following error messages before the system hangs: "Kernel Panic", "Attempted to kill init", "init not tainted"

(With the init script below there is a error saying:"sh: can't access tty; job control turned off". I know why it's there - but don't know if it is connected to this problem.)

This information may be important:
- The machine boots from a usb-harddisk
- /sbin/init on the new root is available
- the system on newroot is sane and runs perfect standalone (without initramfs)
- the system on newroot uses baselayout-2 with openrc
- busybox is built as static binary
- busybox version is v1.15.3

Here is the relevant data:

My uname -a on that machine:

Code:

Content of the initramfs:

Code:

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved