Sponsored Content
Top Forums Shell Programming and Scripting Creating executable script--please help Post 302699793 by smitra on Wednesday 12th of September 2012 10:00:27 AM
Old 09-12-2012
Hi Pamu,
Thank for the reply. I tried to put space in the square bracket. But still the same problem And I am not sure how to fix the loop. Smilie

Code:
osch=0
echo "1. Delete row from file"
echo "2. Delete columns from file"
echo "Select your choice [1 or 2]?"
read osch
if [ $osch -eq 1 ]; 
then
        echo "Enter row numbers with space"
        read x
        echo 'You entered this line: ' $x
        set -A rarray $x
        do 
                awk 'NR!={rarray[@]}' INPUT > INPUT_modified
        done
        echo "Modified file is created"
fi

if [ $osch -eq 2 ]; 
then
        echo "Enter column numbers with space"
	read y
        echo 'You entered this line: ' $y
	set -A rarray $y
        do 
	     awk '{for(i=1;i<=NF;i++)if(i!={rarray[@]})printf '%s', $i OFS;print""}' INPUT > INPUT_modified
        done
        echo "Modified file is created"
fi

Here are the same error again:
Code:
1. Delete row from file
2. Delete columns from file
Select your choice [1 or 2]?
1
./test-array: line 14: syntax error near unexpected token `do'
./test-array: line 14: `        do '

 

10 More Discussions You Might Find Interesting

1. Programming

problem in creating executable for a client program

Hi, I am trying to run simple client server c program in unix.At the compling stage server is creating an executable but the client is not. below is the link to the source codes: http://www.cs.rpi.edu/courses/sysprog/sockets/server.c http://www.cs.rpi.edu/courses/sysprog/sockets/client.c ... (2 Replies)
Discussion started by: konas
2 Replies

2. UNIX for Dummies Questions & Answers

creating executable for every C file

hello Folks, once we compile any C code on Linux, we run the code using "./a.out".. but can we have an executable for every program so that we can run the code directly without compiling the code every time. just run the executable and get the output! Thanks! (7 Replies)
Discussion started by: compbug
7 Replies

3. OS X (Apple)

What's The Easiest Route To Creating A Unix Executable File for Terminal?

I've seen the executable open in the application OmniOutliner, can I create an executable with this app? I'd like to be able to create the unix executable and insert it into terminal, but I'm not sure if the Omni app will allow me to create it. Any one have any ideas or possibly familiar with... (10 Replies)
Discussion started by: unimachead
10 Replies

4. UNIX for Dummies Questions & Answers

need help making a script executable

making a script in vi to create a shell script called wherearethey by entering the following script: echo -n "Who are you looking for: "read userif then list=`w | grep $user | cut -c19-30` if then echo "The user $user is logged in from $list" else echo "The user $user is not logged in... (3 Replies)
Discussion started by: curtner
3 Replies

5. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

6. Shell Programming and Scripting

Script executable only for one person at same time

Hi My question: Is there a way to lock a script if its already running for other users? Like if i want to start a script, that is running by another user, there will be a message: Hey, you cant start the script because its running by another user, try it later. my idea was that the... (10 Replies)
Discussion started by: DarkSwiss
10 Replies

7. UNIX Desktop Questions & Answers

creating an executable file from shell scripts

Hi Friends, I have a shell script which does some operations etc, would it be possible to create an executable file out from this shell script? meaning the executable file is not editable, thus the source code will not be visible to other users for copyright reasons. Please help, thanks! (1 Reply)
Discussion started by: kokoro
1 Replies

8. Shell Programming and Scripting

How to produce a executable Oracle script from bash script?

Hi here's my code ${ORACLE_HOME}/bin/sqlplus /nolog <<!EOF --step 5 create db script start set feedback off set heading off set echo off conn / as sysdba spool ${ORACLE_SID}_db_link.sql SELECT 'CREATE '||DECODE(U.NAME,'PUBLIC','public ')||'DATABASE LINK '||CHR(10)... (2 Replies)
Discussion started by: jediwannabe
2 Replies

9. OS X (Apple)

Creating An Executable On The Fly...

Hi all... Had an idea tonight which could really enhance shell scripting for me. Yes I am aware there could be difficulties but...... Creating a C script inside the shell script to do a task, (a simple text print to stdout in this example), compiling it on the fly, making sure it is... (4 Replies)
Discussion started by: wisecracker
4 Replies

10. Shell Programming and Scripting

Making any script executable

Hi all, I'm new to Unix so just wanted some help. I've been self learning and came accross a question online that I was trying. It is to make any shell script executable, the name of the file is to be made executable. I would use nano and type in something like #! /bin/bash Chmod +x... (4 Replies)
Discussion started by: HelenaR
4 Replies
MYSQL_FETCH_ASSOC(3)							 1						      MYSQL_FETCH_ASSOC(3)

mysql_fetch_assoc - Fetch a result row as an associative array

SYNOPSIS
Warning This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include: omysqli_fetch_assoc(3) o PDOStatement::fetch array mysql_fetch_assoc (resource $result) DESCRIPTION
Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead. mysql_fetch_assoc(3) is equiv- alent to calling mysql_fetch_array(3) with MYSQL_ASSOC for the optional second parameter. It only returns an associative array. o $ result -The result resource that is being evaluated. This result comes from a call to mysql_query(3). Returns an associative array of strings that corresponds to the fetched row, or FALSE if there are no more rows. If two or more columns of the result have the same field names, the last column will take precedence. To access the other column(s) of the same name, you either need to access the result with numeric indices by using mysql_fetch_row(3) or add alias names. See the example at the mysql_fetch_array(3) description about aliases. Example #1 An expanded mysql_fetch_assoc(3) example <?php $conn = mysql_connect("localhost", "mysql_user", "mysql_password"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("mydbname")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $sql = "SELECT id as userid, fullname, userstatus FROM sometable WHERE userstatus = 1"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } // While a row of data exists, put that row in $row as an associative array // Note: If you're expecting just one row, no need to use a loop // Note: If you put extract($row); inside the following loop, you'll // then create $userid, $fullname, and $userstatus while ($row = mysql_fetch_assoc($result)) { echo $row["userid"]; echo $row["fullname"]; echo $row["userstatus"]; } mysql_free_result($result); ?> Note Performance An important thing to note is that using mysql_fetch_assoc(3) is not significantly slower than using mysql_fetch_row(3), while it provides a significant added value. Note Field names returned by this function are case-sensitive. Note This function sets NULL fields to the PHP NULL value. mysql_fetch_row(3), mysql_fetch_array(3), mysql_data_seek(3), mysql_query(3), mysql_error(3). PHP Documentation Group MYSQL_FETCH_ASSOC(3)
All times are GMT -4. The time now is 09:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy