Need Help On Shell Script..

I have serveral nodes related files under /var/lib/ directory as shown below:

Code:
machine001.cluster.org 
machine002.cluster.org
machine003.cluster.org
machine004.cluster.org

I am trying to write a shell script which first finds out how many number of files are present in this directory. Then it should fetch the first name like machine001, machine002, machine003 etc. Then it should fetches ipaddress, hostname and netmask under machine001 first, then store it in some variable. Repeat this for all the nodes. How will the script look like?


Similar Content



Automating Script To Run Every Minute Through Other Manually Created User Using Crond

Hy All,

I have two nodes running RHEL 6.4 which are in cluster. I have clustered httpd service. Now I have certain application suppose X which reside in SAN partition. Now my job is to only automate this script to run by analyzing httpd status. I have successfully created the script apptrigger.sh whose content is given below,

-bash-4.1$ cat apptrigger.sh
a=0
b=0
c=0
d=0
a="service httpd status"
b=`eval $a`
##### CHECKING WHETHER HTTPD SERVICE IS RUNNING OR NOT #####
if [ "$b" != "httpd is stopped" ]; then
c="bash /switchapp/switch/ezlinkenterprise/bin/ezlink-cluster.sh status"
d=`eval $c`
##### CHECKING WHETHER EZ IS RUNNING OR NOT #####
if [ "$d" != "EzTaskMgr is Running" ]; then
ezstart
fi
fi

I have created this script in say test user. Now when I put this script to automate or run every minute through test user and defined its value in crontab -e of test user whose content is as shown below
$crontab -l
* * * * * /bin/bash /home/test/apptrigger.sh

but this script is running as root user so I cannot get the o/p
I think some environment variable need to be set. Anyone can guide me with this step? Thanks for your views and suggestion.

What Exactly Is PATH

books say that PATH variable contains the locations where the shell searches the commands to execute them.

I created a shell script and saved it in /home/user/Downloads directory and then i ran this script from the /home/user/Downloads directory. It did not execute.

however when i did set the path
export PATH=$PATH:/bin/sh within /home/user/Downloads directory, the shell script executed. Does it not mean that PATH variable is holding the locations of the shell program rather than the commands that are to be executed?

everytime i have to give the location of the shell i.e /bin/sh in the PATH variable no matter from where i am executing my script

Shell Scripting

Please tell me for shell script..
I m writing the script.
In that script i written the 1 function and in that function i have to write the contents in existing file
so i write,
cat > /etc/puppet/manifests/init.pp
{
ensure => present,
}
.
But it caanot write the changes in ssh machine
so what i can do in my script?
Please help me...

RH 5 Cluster Fence Problem On Vitual Box

I created 3 test machine and made them into cluster.
On Virtual
"Virtual Machine Manager 0.9.0"
Machines them selves are CentOS 5.11.

Code:
<cluster name="mycluster" config_version="3">
   <clusternodes>
     <clusternode name="one" nodeid="1">
         <fence>
         </fence>
     </clusternode>
     <clusternode name="two" nodeid="2">
         <fence>
         </fence>
     </clusternode>
     <clusternode name="three" nodeid="3">
         <fence>
         </fence>
     </clusternode>
   </clusternodes>
   <fencedevices>
   </fencedevices>
   <rm>
   </rm>
</cluster>

When I start cman service. I see get this:

Code:
[root@one ~]# time service cman restart
Stopping cluster: 
   Stopping fencing... done
   Stopping cman... done
   Stopping ccsd... done
   Unmounting configfs... done
                                                           [  OK  ]
Starting cluster: 
   Loading modules... done
   Mounting configfs... done
   Starting ccsd... done
   Starting cman... done
   Starting daemons... done
   Starting fencing... failed

                                                           [FAILED]

real	5m7.353s
user	0m0.063s
sys	0m0.095s
[root@one ~]#

clustat:

Code:
[root@one ~]# clustat 
Cluster Status for mycluster @ Tue Jun  2 11:10:28 2015
Member Status: Inquorate

 Member Name                                            ID   Status
 ------ ----                                            ---- ------
 one                                                        1 Online, Local
 two                                                        2 Offline
 three                                                      3 Offline

[root@one ~]#

Thank you.

Need A Shell Scrit Urgent Description In Message

HI Everyone, need a shell script which checks size of a directory and if it gets greater than 1 GB then delete all the files in it.

ex: dir : /var/log/

/log contains numerous .log files, so script should delete .log files always when /log size is greater than 1 GB , it should not delete the directory

SFTP Shell Script

Hi,
I am looking for a simple shell script that allows for sftp to be run from the server to another server (Windows). I would like the script to be passed parameters suchas destination server, Id, password, Directory structure/folder name, file name etc...
Need some help to know how to start with and it would be great if someone help me with any sample sftp shell script

Linux Os Clustering?

Hy,
I am new to linuxquestion.org, however i am mid-level linux administrator.

As per my scenario, I want to cluster python and java services in two nodes running RHEL 6.4. Till now by watching tutorial I have seen application level clustering of linux for eg: webserver, mysql database and so on. However I haven't found any with python & java clustering.
I am already familiar with windows clustering having clustered ip of the two nodes. In my scenario, we have both the options open either going with active-active or active-passive cluster. So I want to some sort of idea to achieve linux os clustering and hence obtained clustered ip.
Further any idea on how this service will float from one node to another. Further, I cannot get to the fencing mechanism in Linux. Any idea for this will be helpful to understand.

Hope to get positive respond ASAP. Thanks in advance for those who help me with this.

How To Run Shell Script In Any Folder Except The Folder Which Contains The Shell Script

I am using a shell script named by test.sh, for example containing
Code:
address="$PWD"
echo "$address"

.
If I put it in folder temp1, and run test.sh, then it will give me the address of the current directory. But if I am now in folder temp2, and I want to run test.sh, I always need to copy test.sh to folder temp2, and then run it. Is there a way that I can run test.sh without copying it? I am not root user.

Sending SMB Client Commands Through Shell Script

Hello.

I have a shell script, which I am using to access the SMB Client:

Code:
#!/bin/bash
cd /home/username
smbclient //link/to/server$ password -W domain -U username
recurse
prompt
mput baclupfiles
exit

Right now, the script runs, accesses the server, and then asks for a manual input of the commands.

Can someone show me how to get the commands:
Code:
recurse, prompt, mput baclupfiles and exit

to be run by the shell script please?

Duplicate Folder Creation While Using Mkdir In A Script

Hello,

I am setting up a linux server for gaming and I am using a script to update the files automatically and create a folder with a certain name.

Code:
# !/bin/bash

# A convenience function, to save us some work
update_server() {
	# Read the app id and the directory into a variable

	APP_ID=$1
	DIR=$2

	# Create the directory ( if it does not exist already )
	if [ ! -d "$HOME/$DIR" ]; then
		mkdir -p "$HOME/$DIR"
	fi

	# Uh-oh, it looks like we still have no directory. Report an error.
	if [ ! -d "$HOME/$DIR" ]; then
		# Describe what went wrong
		echo "ERROR! Cannot create directory $HOME/$DIR!"

		# Exit with status code 1 ( which indicates an error )
		exit 1
	fi

	# Call SteamCMD with the app ID we provided and tell it to install
	./bin/steamcmd.sh +login anonymous +force_install_dir "$HOME/$DIR" +app_update $APP_ID validate +quit
}

# Now the script actually runs update_server ( which we just declared above ) with the id of the application ( 4020 is Garry's Mod ) and the name of the directory we want the server to be hosted from:

update_server 4020 "gmodserver"

exit 0

When I run this script, it creates 2 folders on my server : gmodserver and gmodserver? There is no files downloaded in gmodserver. All the files are downloaded in gmodserver?

I looked for a few hours on how to solve this problem but I have no idea what the added ? might be so I am lost as to what to look for. Could you help me on figuring this out?

Thank you.

edit : I am using ubuntu 15.04 x64 if it makes a difference.