Sponsored Content
Full Discussion: Script syntax help
Top Forums Shell Programming and Scripting Script syntax help Post 302933785 by RudiC on Monday 2nd of February 2015 09:38:49 AM
Old 02-02-2015
Trying to understand your script I figure that you iterate through the pass_file line by line, read user and pass from it and run "mysql" in background with these two parameters, limiting the number of concurrent background processes. Some questions:
- do you really need to evaluate the file size in every loop? Does it change?
- do you really need to check $ip existence in every loop (even more as you check $1 in the second line and exit if NULL)
- do you really want to skip the actual user/pass if the process count is greater than your limit (and just sleep 15)?

Consider changing your script to sth like (untested, just for pointing you in some direction):
Code:
while read user pass REST
  do while [[ $(ps -eaf | grep -c [m]ysql) -gt 50 ]]
           do sleep 15
           done      
     ./mysql $ip $user $pass &
  done < pass_file

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script syntax checking

Is it possible to check the script syntax with some sort of command...? Without running the script . I'm using Sun Solaris (3 Replies)
Discussion started by: bjornrud
3 Replies

2. Shell Programming and Scripting

Syntax error in a script...

Hi All, I have been fighting with a syntax error for the last 2 days, still haven't got the solution. Could you please help me, your help will be greatly appreciated. In my script I am getting a error in a for loop, its similar to the one as is below. for v_id in v1 v2 v3 v4 do... (8 Replies)
Discussion started by: rajus19
8 Replies

3. Shell Programming and Scripting

Syntax error in script

I get this error when I try to run my script (BTW, this is a simple script I am supposed to write for my class) $ menuscript menuscript: syntax error at line 89 : `"' unmatched $ Here is the code (Any help is greatly appreciated) (Line numbers included) 1 #!/bin/ksh 2 ... (2 Replies)
Discussion started by: KindHead
2 Replies

4. Shell Programming and Scripting

syntax error on script

Hello all, I am trying to write a little script to create a file and I keep getting the below error and cant see where my syntax mistake(s) is. please help... the script: FILE="/u/e477059/Unix_Machines/LISTS" for X in `cat ${FILE}/list` do ssh $X "echo $X; cd /var/tmp; ... (2 Replies)
Discussion started by: rookieuxixsa
2 Replies

5. Shell Programming and Scripting

Syntax error with a script

Hi I not sure what is wrong with my script... when I try to run it I get the follow error: "remove: syntax error at line 77: `end of file' unexpected" Thanks in advance for any help. ans=y while do while : do echo "Please enter a name that you... (3 Replies)
Discussion started by: simpsonjr
3 Replies

6. Shell Programming and Scripting

Syntax error in script

Hey guys keep having problems with the below script syntax error near unpexpected token '0' exit 0 I have two directorys backups and Usr in the usr i have sub dir's wp,ss,pic which i would like to back up (copy those directorys to the backups directory) with user acknowledgement from command line.... (2 Replies)
Discussion started by: Spartukus
2 Replies

7. Shell Programming and Scripting

sftp syntax in script

I am have FTP syntax like below in my bash shell script ftp -n <<END open $Server user $FtpUser $FtpPwd cd $FtpPath binary put $Filename.gz bye END Now I wanted to change this into SFTP. I tried... (4 Replies)
Discussion started by: sbmk_design
4 Replies

8. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

9. UNIX for Dummies Questions & Answers

Syntax Error Script

Hi guys i'd like to show you this code of my script, where i couldn't find this error " #! /bin/bash #copiabin.sh: copia todos los archivos ejecutables a bin if then mkdir $HOME/bin fi # copia de archivos y contador N N=0 for ARCH in * do if # Si el archivo es... (9 Replies)
Discussion started by: Newer
9 Replies

10. Shell Programming and Scripting

Help with syntax of Python script

I added some fields to some existing code, and all was well. Just added a few more, and BAM. I've looked this over forever, but being a newbie to Python, I see NOTHING. The code generates syslog messages, and the new fields were added around "rtp_lapse*" . Any clues??? #!/usr/bin/python ... (4 Replies)
Discussion started by: gmark99
4 Replies
FSCK(8) 						    BSD System Manager's Manual 						   FSCK(8)

NAME
fsck -- file system consistency check and interactive repair SYNOPSIS
fsck [-Cdfnpvy] [-B | -F] [-T fstype:fsoptions] [-t fstype] [-c fstab] [special | node] ... DESCRIPTION
The fsck utility invokes file system-specific programs to check the special devices listed in the fstab(5) file or in the command line for consistency. It is normally used in the script /etc/rc during automatic reboot. Traditionally, fsck is invoked before the file systems are mounted and all checks are done to completion at that time. If background checking is available, fsck is invoked twice. It is first invoked at the tra- ditional time, before the file systems are mounted, with the -F flag to do checking on all the file systems that cannot do background check- ing. It is then invoked a second time, after the system has completed going multiuser, with the -B flag to do checking on all the file sys- tems that can do background checking. Unlike the foreground checking, the background checking is started asynchronously so that other system activity can proceed even on the file systems that are being checked. If no file systems are specified, fsck reads the table /etc/fstab to determine which file systems to check. Only partitions in /etc/fstab that are mounted ``rw'', ``rq'' or ``ro'' and that have non-zero pass number are checked. File systems with pass number 1 (normally just the root file system) are always checked one at a time. If not in preen mode, the remaining entries are checked in order of increasing pass number one at a time. This is needed when interaction with fsck is required. In preen mode, after pass 1 completes, all remaining file systems are checked, in pass number order running one process per disk drive in parallel for each pass number in increasing order. In other words: In preen mode all pass 1 partitions are checked sequentially. Next all pass 2 partitions are checked in parallel, one process per disk drive. Next all pass 3 partitions are checked in parallel, one process per disk drive. etc. The disk drive containing each file system is inferred from the shortest prefix of the device name that ends in a digit; the remaining char- acters are assumed to be the partition and slice designators. If the -t or -T flags are not specified, fsck will attempt to determine the file system type and call the appropriated file system check utility. Failure to detect the file system type will cause fsck to fail with a message that the partition has an unknown file system type. The options are as follows: -C Check if the ``clean'' flag is set in the superblock and skip file system checks if file system was properly dismounted and marked clean. -c fstab Specify the fstab file to use. -d Debugging mode. Just print the commands without executing them. Available only if fsck is compiled to support it. -f Force checking of file systems, even when they are marked clean (for file systems that support this). -n Causes fsck to assume no as the answer to all operator questions, except "CONTINUE?". -p Enter preen mode. In preen mode, only a restricted class of innocuous file system inconsistencies will be corrected. If unexpected inconsistencies caused by hardware or software failures are encountered, the check program will exit with a failure. See the manual pages for the individual check programs for a list of the sorts of failures that they correct when running in preen mode. -F Run in foreground mode. The check program for each file system is invoked with the -F flag to determine whether it wishes to run as part of the boot up sequence, or if it is able to do its job in background after the system is up and running. A non-zero exit code indicates that it wants to run in foreground and the check program is invoked. A zero exit code indicates that it is able to run later in background and just a deferred message is printed. -B Run in background mode. The check program for each file system is invoked with the -F flag to determine whether it wishes to run as part of the boot up sequence, or if it is able to do its job in background after the system is up and running. A non-zero exit code indicates that it wanted to run in foreground which is assumed to have been done, so the file system is skipped. A zero exit code indicates that it is able to run in background so the check program is invoked with the -B flag to indicate that a check on the active file system should be done. When running in background mode, only one file system at a time will be checked. Note that back- ground fsck is limited to checking for only the most commonly occurring file system abnormalities. Under certain circumstances, some errors can escape background fsck. It is recommended that you perform foreground fsck on your systems periodically and whenever you encounter file-system-related panics. -t fstype Invoke fsck only for the comma separated list of file system types. If the list starts with ``no'' then invoke fsck for the file system types that are not specified in the list. -v Print the commands before executing them. -y Causes fsck to assume yes as the answer to all operator questions. -T fstype:fsoptions List of comma separated file system specific options for the specified file system type, in the same format as mount(8). FILES
/etc/fstab file system table SEE ALSO
fstab(5), fsck_ffs(8), fsck_msdosfs(8), mount(8) BSD
May 23, 2014 BSD
All times are GMT -4. The time now is 05:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy