SQL script help please - creating 'batches' of rows in a table
I have a table, ADAM_TEST1, that contains just 1 column - AMOUNT:
SQL> desc adam_test1;
Name Null? Type
AMOUNT NUMBER(12)
..I have 5000 rows in this table.
I need to insert rows into another table, ADAM_TEST, which contains these values but also assign each item a unique item_number and a batch_id for every 1000 rows.
SQL> desc adam_test;
Name Null? Type
BATCH_ID NUMBER(4)
ITEM_NUMBER NUMBER(4)
AMOUNT NUMBER(4)
e.g. BATCH_ID 1 will contain 1000 rows with the amounts from ADAM_TEST1 with item_numbers of 1-1000, then BATCH_ID 2 with the next 1000 rows with item numbers 1-1000 etc ...
I can populate the table with 1 batch_id and use a sequence to number them all but I'm having problems splitting them into their batches and resetting the sequence after each batch_id increment.
Some help here would be great!
Thanks,
Adam
technoarcanum wrote:
Here's another way of doing it in a single SQL statement.
Run this and you'll see I've batched my test data up into batches of 10:
insert into test_109 select col_1
,row_number() over (order by col_1)
,ceil(row_number() over (order by col_1)/10)
from test_108;
select * from test_109;Unfortunately that doesn't reset the item number for each batch..
SQL> ed
Wrote file afiedt.buf
1 select empno
2 ,row_number() over (order by empno)
3 ,ceil(row_number() over (order by empno)/10)
4* from emp
SQL> /
EMPNO ROW_NUMBER()OVER(ORDERBYEMPNO) CEIL(ROW_NUMBER()OVER(ORDERBYEMPNO)/10)
7369 1 1
7499 2 1
7521 3 1
7566 4 1
7654 5 1
7698 6 1
7782 7 1
7788 8 1
7839 9 1
7844 10 1
7876 11 2
7900 12 2
7902 13 2
7934 14 2
14 rows selected.
SQL>Instead you need to MOD it...
SQL> ed
Wrote file afiedt.buf
1 select empno
2 ,mod(row_number() over (order by empno)-1,10)+1
3 ,ceil(row_number() over (order by empno)/10)
4* from emp
SQL> /
EMPNO MOD(ROW_NUMBER()OVER(ORDERBYEMPNO)-1,10)+1 CEIL(ROW_NUMBER()OVER(ORDERBYEMPNO)/10)
7369 1 1
7499 2 1
7521 3 1
7566 4 1
7654 5 1
7698 6 1
7782 7 1
7788 8 1
7839 9 1
7844 10 1
7876 1 2
7900 2 2
7902 3 2
7934 4 2
14 rows selected.
SQL>
Similar Messages
-
Gallery script help, please
Gallery script help, please
Hello,
I'm new to actionscript in general, I do know a little...
I foung a gallery script, modified many things, the images
open fine, everything is working, but here's the thing:
the gallery is in 3 sections, red, blue and yellow.
I would like to know how, what, and where to put a script so
that if a "the small red image #1" is clicked, I can load any sort
of a movie on top of the "the BIG red image #1" or #2 or 3 and so
on...same goes for the blue and yellow...
If I figured things correctly on my own...the small thumbnail
images of the gallery are not buttons, that's why I can't attach a
movie (let's say) to them...but it is all written in script, using
the horizontal and vertical position of the mouse to open the large
images of the gallery...
So, I don't know how to figure things out, to attach a
specific movie to a specific thumbnail...
p.s.: I think the script that controls the gallery is in
symbol 120
I really would appreciate the help
Merry Christmas in advance to everyone
Sandra
here are all the files...
http://www.gentro.ca/sandra_test.zipThere's a great tutorial on kirupa...
click
here for link -
Using an SQL Script file to create database in Java? (monkeyDB.sql)
Hello!
I am a writing an SQL Script so that I can re-create my database on another server (im using my laptop to test it on first though).
I'm connecting to mySQL server using JDBC which works fine, but I was wondering
how can I run an entire script file, say myScript.sql from within a Java class??
(an SQL Script is simply a file containing the regular SQL commands and expressions that you might enter at an sql command line prompt)
example of an SQL Scritp: monkeyDB.sql>>
//#create new db
CREATE DATABASE sample_db;
//#set active db
USE sample_db;
//#set table paramaters
CREATE TABLE monkeys
(name CHAR(20),
age INT UNSIGNED,
sex ENUM('M','F')
//#create standard monkeys
INSERT INTO monkeys(name,age,sex) VALUES("Sammy",10,"M");
INSERT INTO monkeys(name,age,sex) VALUES("Muncht",12,"M");
INSERT INTO monkeys(name,age,sex) VALUES("Jill",8,"F");
//#get recordset
SELECT * FROM monkeys WHERE age < 50;Thanks for your help!thanks. :-)
I thought about that too but I didnt want to hard wire it into the code.
I guess it isnt possible to output the script file using some command from the sql library..? -
Run SQL Script from a a Batch File
I'm trying to schedulling a SQL Script by Windows Scheduler:
START
"C:\Program Files\Microsoft SQL Server\100\DTS\Binn\dtexec.exe" /FILE "C:\Users\tstjs\TESTESTESTES.sql" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING EWCDI
PAUSE
However, when I run the batch file it giving the error below:
...sql" due to error 0xC00CE556 "Invalid at the top level of the document. Line 1, Column 1". This happens when loading a package and the file cannot be opened o r loaded correctly into an XML document. This can be the result of either provid
ing an incorrect file name to the LoadPackage method or the XML file specified h aving an incorrect format. End Error
How can I solve that problem?
Thanks!Hi SaQvl,
As Scott metioned, you shall use sqlcmd to execute a tsql script. You can reference the below link
Use the sqlcmd Utility
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
firefox not responding, freezes, sometimes responds after a few minutes, other times a pop-up appears asking if I want to stop script - help please
Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
* Don't make any changes on the Safe mode start window.
See:
* [[Troubleshooting extensions and themes]]
* [[Troubleshooting plugins]]
If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
* Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
* Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit") -
Can we create a new row in a table using a down arrow
Hi,
I am using jdeveloper 11.1.1.6.
For one of my project, I have a requirement where i need to create a new row in table using a down arrow. My client does not want to use mouse clicks. They want to use keyboard as much as possible.(Fast data entry).
Is it possible to create a new row using down arrow. Any pointers will be helpful!
Thanks,
Umeshyou can try this thing
steps
- capture downkey event - may b this help http://www.qualitycodes.com/tip/1/capturing-keys-with-javascript.html
if not google more
-then call from javascript call java method - https://blogs.oracle.com/jdevotnharvest/entry/how-to_call_server_side_java_from_javascript
-then create new row of table VO ..... -
How to create multiple new rows in ADF Table?
Hello,
being new to ADF Faces/BC I managed to display data in an ADF Table and create new entries using the "CreateInsert" operation (one at a time).
Now, the next task is to create multiple new rows at the same time, set some default values and display the new rows in the ADF table. Then the user will enter additional data and commit the new rows.
Where do I step in? In the EntitiyImpl? Can this be handled declaratively or do I have to implement custom method(s) in the AM?
Thanks
GeraldHi John,
I'm still getting the following error
Error(94,144): method getValue() not found in class javax.faces.el.ValueBinding
What should it be casted to?
The code in backing bean is like this..
package view.backing;
//import com.test.model.TestAppModuleImpl;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlPanelGroup;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
//import javax.faces.event.FacesListener;
//import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.faces.component.core.data.CoreColumn;
import oracle.adf.view.faces.component.core.data.CoreTable;
import oracle.adf.view.faces.component.core.input.CoreInputText;
import oracle.adf.view.faces.component.core.nav.CoreCommandButton;
import oracle.adf.view.faces.component.core.output.CoreMessages;
import oracle.adf.view.faces.component.html.HtmlBody;
import oracle.adf.view.faces.component.html.HtmlHead;
import oracle.adf.view.faces.component.html.HtmlHtml;
import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
//import oracle.jbo.server.ViewObjectImpl;
//import view.utils.EL;
public class MultipleInsert1 {
private HtmlHtml html1;
private HtmlHead head1;
private HtmlBody body1;
private CoreMessages messages1;
private HtmlForm form1;
private CoreTable table1;
private CoreColumn column1;
private CoreInputText inputText1;
private CoreColumn column2;
private CoreInputText inputText2;
private CoreCommandButton commandButton1;
private HtmlPanelGroup panelGroup1;
private CoreCommandButton commandButton2;
public void setHtml1(HtmlHtml html1) {
this.html1 = html1;
public void createMultiRows(ActionEvent actionEvent) {
DCBindingContainer dc = (DCBindingContainer) FacesContext.getCurrentInstance().getApplication().createValueBinding("#{bindings}").getValue();
DCIteratorBinding iter = dc.findIteratorBinding("TestView1Iterator");
ViewObject vo = iter.getViewObject();
for (int i=1; i<=5; i++) {
Row newRow = vo.createRow();
newRow.setAttribute("Id", i);
ApplicationModule am = vo.getApplicationModule();
am.getTransaction().commit();
vo.executeQuery();
Do I need to import something else?
Thanks,
Shri. -
Create a new row in a table without using add new row button
I want to add a new row to the table without using the add new row button of the table. I'm not able to display default row in the table. Though if click on apply the record appears after saving in the database. Any thoughts how to implement this functionality.
Here is what you have to do.
1) You have to handle this in processRequest()
2) In the AM code , u need to check if there is already a row exisit or vo is blank
if (vo.getFetchedRowCount() == 0)
// first time
vo.setMaxFetchSize(0); // THIS IS REQUIRED.
Row row = vo.createRow();
vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
else
//If already rows are there then you suppose to insert in the end
// i assume you would have execute your vo
YourVORowImpl row= (YourVORowImpl)vo.getRowAtRangeIndex(0);
vo2.insertRowAtRangeIndex();
It should work. -
T-SQL script help needed on creating a distribution.
Hello Team -
I'm new to T-SQL.
I have a set of sales reps and have accounts assigned to them. I want to be able to take out only those accounts for each
sales rep whose REVMIX won't exceed more than 10% (summing up the total revmix and capping it to <=10%). Not sure how to get to it.
Kindly help. Below is how the data looks like.
SALES REP
ACCOUNT_ID
REVENUE
TOTALREVENUE
REVMIX
23626
123456791
100
$44,100
0.2%
23626
123456793
300
$44,100
0.7%
23626
123456795
500
$44,100
1.1%
23626
123456797
700
$44,100
1.6%
23626
123456799
900
$44,100
2.0%
23626
123456801
1100
$44,100
2.5%
23626
123456803
1300
$44,100
2.9%
23626
123456805
1500
$44,100
3.4%
23626
123456807
1700
$44,100
3.9%
23626
123456809
1900
$44,100
4.3%
23626
123456811
2100
$44,100
4.8%
23626
123456813
2300
$44,100
5.2%
23626
123456815
2500
$44,100
5.7%
23626
123456817
2700
$44,100
6.1%
23626
123456819
2900
$44,100
6.6%
23626
123456821
3100
$44,100
7.0%
23626
123456823
3300
$44,100
7.5%
23626
123456825
3500
$44,100
7.9%
23626
123456827
3700
$44,100
8.4%
23626
123456829
3900
$44,100
8.84%
23626
123456831
4100
$44,100
9.30%
236267
123456802
4300
167500
2.57%
236267
123456814
4500
167500
2.69%
236267
123456826
4700
167500
2.81%
236267
123456838
4900
167500
2.93%
236267
123456850
5100
167500
3.04%
236267
123456862
5300
167500
3.16%
236267
123456874
5500
167500
3.28%
236267
123456886
5700
167500
3.40%
236267
123456898
5900
167500
3.52%
236267
123456910
6100
167500
3.64%
236267
123456922
6300
167500
3.76%
236267
123456934
6500
167500
3.88%
236267
123456946
6700
167500
4.00%
236267
123456958
6900
167500
4.12%
236267
123456970
7100
167500
4.24%
236267
123456982
7300
167500
4.36%
236267
123456994
7500
167500
4.48%
236267
123457006
7700
167500
4.60%
236267
123457018
7900
167500
4.72%
236267
123457030
8100
167500
4.84%
236267
123457042
8300
167500
4.96%
236267
123457054
8500
167500
5.07%
236267
123457066
8700
167500
5.19%
236267
123457078
8900
167500
5.31%
236267
123457090
9100
167500
5.43%
236268
123457102
9300
136500
6.81%
236268
123457114
9500
136500
6.96%
236268
123457126
9700
136500
7.11%
236268
123457138
9900
136500
7.25%
236268
123457150
10100
136500
7.40%
236268
123457162
10300
136500
7.55%
236268
123457174
10500
136500
7.69%
236268
123457186
10700
136500
7.84%
236268
123457198
10900
136500
7.99%
236268
123457210
11100
136500
8.13%
236268
123457222
11300
136500
8.28%
236268
123457234
11500
136500
8.42%
236268
123457246
11700
136500
8.57%This is close to a live data. There are about 23 rows here from the table. Sum(REVENUE) for the 10 rows would add up to 2380114.397. I will get 10% MIX if I divide it with RUNNINGTOTAL_REVENUE. For some reason when
I'm applying where condition it's not returning those first 10 rows. Not sure what the problem is. :(
SALESREP
ACCOUNT_ID
REVENUE
RUNNINGTOTAL_REVENUE
MIX
236300
ACCOUNT1
17917.83
23451885.59
0%
236300
ACCOUNT2
67402.07
23451885.59
0%
236300
ACCOUNT3
69576.646
23451885.59
0%
236300
ACCOUNT4
82828.84
23451885.59
0%
236300
ACCOUNT5
130955.866
23451885.59
1%
236300
ACCOUNT6
153865.04
23451885.59
1%
236300
ACCOUNT7
316329.34
23451885.59
1%
236300
ACCOUNT8
476030
23451885.59
2%
236300
ACCOUNT9
483660.01
23451885.59
2%
236300
ACCOUNT10
581548.755
23451885.59
2%
236300
ACCOUNT11
669007.05
23451885.59
3%
236300
ACCOUNT12
683942.12
23451885.59
3%
236300
ACCOUNT13
748481.98
23451885.59
3%
236300
ACCOUNT14
878047.8
23451885.59
4%
236300
ACCOUNT15
1127457.05
23451885.59
5%
236300
ACCOUNT16
1221103.91
23451885.59
5%
236300
ACCOUNT17
1422627.56
23451885.59
6%
236300
ACCOUNT18
1492686.19
23451885.59
6%
236300
ACCOUNT19
1698136.33
23451885.59
7%
236300
ACCOUNT20
2536279.246
23451885.59
11%
236300
ACCOUNT21
2618973.05
23451885.59
11%
236300
ACCOUNT22
2860847.283
23451885.59
12%
236300
ACCOUNT23
3114181.627
23451885.59
13% -
SQL SCRIPT ERROR PLEASE HELP!!!
DROP TABLE CUSTOMERUSER CASCADE CONSTRAINTS;
CREATE TABLE CUSTOMERUSER
( Username VARCHAR(10) NOT NULL,
UserID VARCHAR(15) NOT NULL,
Pword VARCHAR(30),
Street VARCHAR(15),
City VARCHAR(15),
Postalcode VARCHAR(15),
Phone VARCHAR(10),
Email VARCHAR(16),
PRIMARY KEY (Username,UserID));
DROP TABLE ADMINISTRATOR CASCADE CONSTRAINTS;
CREATE TABLE ADMINISTRATOR
( Username VARCHAR(10) NOT NULL,
EmployeeID VARCHAR(15) NOT NULL,
Pword VARCHAR(30),
AdminType VARCHAR(15),
PRIMARY KEY (Username,EmployeeID));
DROP TABLE FLIGHT CASCADE CONSTRAINTS;
CREATE TABLE FLIGHT
( FlightID VARCHAR(10) NOT NULL,
FlightNumber VARCHAR(15) NOT NULL,
Airline VARCHAR(30),
AvailableSeats INT,
PRIMARY KEY (FlightID));
DROP TABLE RESERVATION CASCADE CONSTRAINTS;
CREATE TABLE RESERVATION
( ReservationNumber VARCHAR(10) NOT NULL,
IsPaid VARCHAR(4) NOT NULL,
dayof VARCHAR(10),
FlightID VARCHAR(10) NOT NULL,
UserID VARCHAR(15) NOT NULL,
PRIMARY KEY (ReservationNumber,UserID),FOREIGN KEY (FlightID) REFERENCES FLIGHT(FlightID),FOREIGN KEY (UserID) REFERENCES customeruser(UserID));
DROP TABLE PAYMENT CASCADE CONSTRAINTS;
CREATE TABLE PAYMENT
( PaymentID VARCHAR(10) NOT NULL,
PaymentAmount VARCHAR(15) ,
PaymentDate VARCHAR(30),
ReservationNumber INT NOT NULL,
PRIMARY KEY (PaymentID),FOREIGN KEY (ReservationNumber) REFERENCES RESERVATION(ReservationNumber));
DROP TABLE FLIGHTSCHEDULE CASCADE CONSTRAINTS;
CREATE TABLE FLIGHTSCHEDULE
( FlightNumber VARCHAR (15) NOT NULL,
Fromw VARCHAR(25) ,
Wto VARCHAR(25),
DepatureDate VARCHAR(10) ,
ArrivalDate VARCHAR(10),
Class VARCHAR(10) ,
DepatureTime VARCHAR(8),
ArrivalTime VARCHAR (8) NOT NULL,
PRIMARY KEY (FlightNumber),FOREIGN KEY (FlightNumber) REFERENCES FLIGHT(FlightNumber));
When i execute the RESERVATION section. it gaving me a error called " *
ERROR at line 7:
ORA-02270: no matching unique or primary key for this column-list
How to fix that?in TABLE RESERVATION the FOREIGN KEY (UserID) REFERENCES customeruser(UserID) expects the primary key of TABLE CUSTOMERUSER to be UserID (not PRIMARY KEY (Username,UserID) as in your case) or the TABLE CUSTOMERUSER having an unique index on UserID.
Regards
Etbin
Edited by: Etbin on 3.12.2011 22:22
You might be sorry defining DepartureDate as VARCHAR2(10) and DepartureTime as VARCHAR2(8) instead of Departure DATE (time component included)
the same for ArrivalDate in TABLE FLIGHTSCHEDULE
in TABLE RESERVATION there is dayof VARCHAR(10) too -
Installing Oracle 8i and Forms 6i Messes up SQL PLUS HELP PLEASE!!!
I have Win2K, originally I had Oracle 8i (home was "orant"), and I was able to connect to oracle through SQL PLUS. Then I installed the Forms 6i (downloaded version from OTN) on separate home , and I couldn't invoke forms, so I copied tnsnames.ora from 8i to forms' directory, and I lost connection with oracle sqlplus.
I then re-installed first forms on "orant" and then 8i on "ornat\ora8i" and I still cannot connect sqlplus. I have homeworks due, and cannot afford to go to lab late nights, so please help me!!!hI,
I have the problem backward!
I created a profile then assigned it to the user, then I launched the apps thr the browser, it worked prompting the message "...password will expire in 3 days..."
Now I reassigned the Default profile back to the user which does not expire the password, launched the apps again it still prompted that password warning message! I even deleted the profile that was first created, still got the warning.
I tried to do it alter user in SqlPlus but not able to connect to database using the same System account as Sysdba (used to connect in Enterprise Console successfully), received error :Insufficient Privileges.
What is wrong ? Thanks.
Win2000,
DB 9.2.1.0
9iDS 9.0.2
Netscape 4.75 -
Oracle AS connect to MS SQL server - help please.
hi there
can anyone tell or show me how to connect Oracle app server to MS sql server? thanksHi Tom,
For stand-alone OC4J (any version), you need to add an appropriate entry to the "data-sources.xml" file (in the "j2ee/home/config" subdirectory) and put the JDBC driver file(s) into the "j2ee/home/lib" subdirectory. On my OC4J 9.0.3 distribution (on my Windows XP machine), there already is a "ms-sql.xml" file in the "j2ee/home/config/database-schemas" subdirectory. If you don't have one, then you may need to create one, or if you do already have one, you may need to modify it. More information can be found at these Web sites:
http://www.orionserver.com
http://www.orionsupport.com
http://www.atlassian.com
http://www.elephantwalker.com
Hope this helps you.
Good Luck,
Avi. -
Wmii/dash scripting help please
So heres the thing, I pretty much suck at scripting .
I get by in tiling wm's simply by observing, modifying, and eventually learning through trial and error.
So Ive been playing around with wmii lately and Ive hacked up my wmiirc to do what I want as best I can with what limited knowledge I have, but I need more.
First problem, Im trying to make wmii have custom tag titles while still using alt + 0-9 instead of using alt + t and typing the title every time.
heres what I did to achieve this
# for i in 0 1 2 3 4 5 6 7 8 9; do
# cat <<!
#Key $MODKEY-$i # Move to the numbered view
# wmiir xwrite /ctl view "$i"
#Key $MODKEY-Shift-$i # Retag selected client with the numbered tag
# wmiir xwrite /client/sel/tags "$i"
# done
Key $MODKEY-1
wmiir xwrite /ctl view "web"
Key $MODKEY-Shift-1
wmiir xwrite /client/sel/tags "web"
Key $MODKEY-2
wmiir xwrite /ctl view "ctrl"
Key $MODKEY-Shift-2
wmiir xwrite /client/sel/tags "ctrl"
Key $MODKEY-3
wmiir xwrite /ctl view "stat"
Key $MODKEY-Shift-3
wmiir xwrite /client/sel/tags "stat"
Key $MODKEY-4
wmiir xwrite /ctl view "msg"
Key $MODKEY-Shift-4
wmiir xwrite /client/sel/tags "msg"
Key $MODKEY-5
wmiir xwrite /ctl view "img"
Key $MODKEY-Shift-5
wmiir xwrite /client/sel/tags "img"
Key $MODKEY-6
wmiir xwrite /ctl view "vid"
Key $MODKEY-Shift-6
wmiir xwrite /client/sel/tags "vid"
Key $MODKEY-7
wmiir xwrite /ctl view "misc"
Key $MODKEY-Shift-7
wmiir xwrite /client/sel/tags "misc"
Key $MODKEY-8
wmiir xwrite /ctl view "misc1"
Key $MODKEY-Shift-8
wmiir xwrite /client/sel/tags "misc1"
Key $MODKEY-9
wmiir xwrite /ctl view "misc2"
Key $MODKEY-Shift-9
wmiir xwrite /client/sel/tags "misc2"
Key $MODKEY-0
wmiir xwrite /ctl view "misc3"
Key $MODKEY-Shift-0
wmiir xwrite /client/sel/tags "misc3"
Now this does work, but the problem is that now tags are listed on the tag bar alphabetically rather then numerically like I intended. Example alt + 1 (which is now web) actually ends up being the last tag in the list rather then the first because web starts with w.
I.E [crtl][msg][stat][web] instead of [web][ctrl][stat][msg] like I intended.
So I guess the question is how can I fix this so theyre listed in accordance with the key thats pressed rather then alphabetically? Is this possible in wmii?
Also I dont want to change the keys (i.e. make web 9 instead of 1 so its last on the keyboard too). I like the web=1,ctr=2l,stat=3,msg=4 layout that I chose in my config, I just dont like how theyre out of order on the bar.
Next problem, I want to autostart specific applications on specific tags and in a specific arrangement.
heres what I did to achieve this
# Autostart (this is ghetto, I know)
echo -n view ctrl | wmiir write /ctl;urxvtc -e ssh 192.168.1.55 -p 228 &
urxvtc -e ssh [email protected] -p 228 &
sleep 1.5 && urxvtc &
sleep 2 && wmiir xwrite /tag/sel/ctl send sel right &
sleep 2.5 && echo -n view stat | wmiir write /ctl;urxvtc -e vifm &
sleep 2.5 && urxvtc -e alsamixer &
sleep 3 && urxvtc -e htop &
sleep 3.5 && wmiir xwrite /tag/sel/ctl send sel left &
sleep 4 && echo -n view msg | wmiir write /ctl;pidgin &
sleep 3.5 && echo -n view web | wmiir write /ctl;wmiir xwrite /tag/sel/ctl colmode sel stack;uzbl-browser &
This also works, but it seems a bit too hackish if you ask me. It also takes a while to go through the tags and open things one at a time like this. Surely there must be a way to achieve the same results without all the sleep and manual client placement commands. Im looking for a way to open everything simultaneously and have it go directly where its supposed to.
So what would be the better way to do this?
And lastly heres the complete wmiirc for reference. If anybody has any tips or suggestions about anything please share.
#!/bin/dash -f
# Configure wmii
wmiiscript=wmiirc # For wmii.sh
. wmii.sh
# Configuration Variables
MODKEY=Mod1
UP=k
DOWN=j
LEFT=h
RIGHT=l
# Bars
noticetimeout=5
noticebar=/rbar/!notice
# Colors tuples: "<text> <background> <border>"
export WMII_NORMCOLORS='#a7a15e #262626 #3e3e3e'
export WMII_FOCUSCOLORS='#262626 #a7a15e #3e3e3e'
export WMII_BACKGROUND='#262626'
set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS)
# Font
export WMII_FONT='xft:Terminus-8'
#export WMII_FONT='-dec-terminal-bold-*-*-*-*-*-*-*-*-*-*-*'
# Terminal
export WMII_TERM="urxvtc"
# Menu history
hist="${WMII_CONFPATH%%:*}/history"
histnum=5000
# Column Rules
wmiir write /colrules <<!
/.*/ -> 58+42
# /.*/ -> 62+38 # Golden Ratio
# Tagging Rules
wmiir write /rules <<!
# Apps with system tray icons like to their main windows
# Give them permission.
#/^Pidgin:/ allow=+activate
# Float Apps
/MPlayer/ floating=on
/feh/ floating=on
/gimp/ floating=on
/^Pidgin:/ floating=on
# ROX puts all of its windows in the same group, so they open
# with the same tags. Disable grouping for ROX Filer.
#/^ROX-Filer:/ group=0
# Status Bar Info
status() {
echo -n $(uptime | sed 's/.*://; s/,//g') '|' $(date +%a' '%b' '%d' '%r)
# Generic overridable startup details
startup() { witray & }
local_events() { true;}
wi_runconf -s wmiirc_local
startup
echo $WMII_NORMCOLORS | wmiir create $noticebar
# Event processing
events() {
cat <<'!'
# Events
Event CreateTag
echo "$WMII_NORMCOLORS" "$@" | wmiir create "/lbar/$@"
Event DestroyTag
wmiir remove "/lbar/$@"
Event FocusTag
wmiir xwrite "/lbar/$@" "$WMII_FOCUSCOLORS" "$@"
Event UnfocusTag
wmiir xwrite "/lbar/$@" "$WMII_NORMCOLORS" "$@"
Event UrgentTag
shift
wmiir xwrite "/lbar/$@" "*$@"
Event NotUrgentTag
shift
wmiir xwrite "/lbar/$@" "$@"
Event LeftBarClick LeftBarDND
shift
wmiir xwrite /ctl view "$@"
Event Unresponsive
client=$1; shift
msg="The following client is not responding. What would you like to do?$wi_newline"
resp=$(wihack -transient $client \
xmessage -nearmouse -buttons Kill,Wait -print \
-fn "${WMII_FONT%%,*}" "$msg $(wmiir read /client/sel/label)")
if [ "$resp" = Kill ]; then
wmiir xwrite /client/$client/ctl slay &
fi
Event Notice
wmiir xwrite $noticebar $wi_arg
kill $xpid 2>/dev/null # Let's hope this isn't reused...
{ sleep $noticetimeout; wmiir xwrite $noticebar ' '; }&
xpid = $!
# Menus
Menu Client-3-Delete
wmiir xwrite /client/$1/ctl kill
Menu Client-3-Kill
wmiir xwrite /client/$1/ctl slay
Menu Client-3-Fullscreen
wmiir xwrite /client/$1/ctl Fullscreen on
Event ClientMouseDown
wi_fnmenu Client $2 $1 &
Menu LBar-3-Delete
tag=$1; clients=$(wmiir read "/tag/$tag/index" | awk '/[^#]/{print $2}')
for c in $clients; do
if [ "$tag" = "$(wmiir read /client/$c/tags)" ]; then
wmiir xwrite /client/$c/ctl kill
else
wmiir xwrite /client/$c/tags -$tag
fi
if [ "$tag" = "$(wi_seltag)" ]; then
newtag=$(wi_tags | awk -v't='$tag '
$1 == t { if(!l) getline l
print l
exit }
{ l = $0 }')
wmiir xwrite /ctl view $newtag
fi
done
Event LeftBarMouseDown
wi_fnmenu LBar "$@" &
# Actions
Action showkeys
echo "$KeysHelp" | xmessage -file - -fn ${WMII_FONT%%,*}
Action quit
wmiir xwrite /ctl quit
Action exec
wmiir xwrite /ctl exec "$@"
Action rehash
wi_proglist $PATH >$progsfile
Action status
set +xv
if wmiir remove /rbar/status 2>/dev/null; then
sleep 2
fi
echo "$WMII_NORMCOLORS" | wmiir create /rbar/status
while status | wmiir write /rbar/status; do
sleep 1
done
# Key Bindings
KeyGroup Moving around
Key $MODKEY-$LEFT # Select the client to the left
wmiir xwrite /tag/sel/ctl select left
Key $MODKEY-$RIGHT # Select the client to the right
wmiir xwrite /tag/sel/ctl select right
Key $MODKEY-$UP # Select the client above
wmiir xwrite /tag/sel/ctl select up
Key $MODKEY-$DOWN # Select the client below
wmiir xwrite /tag/sel/ctl select down
Key $MODKEY-space # Toggle between floating and managed layers
wmiir xwrite /tag/sel/ctl select toggle
KeyGroup Moving through stacks
Key $MODKEY-Control-$UP # Select the stack above
wmiir xwrite /tag/sel/ctl select up stack
Key $MODKEY-Control-$DOWN # Select the stack below
wmiir xwrite /tag/sel/ctl select down stack
KeyGroup Moving clients around
Key $MODKEY-Shift-$LEFT # Move selected client to the left
wmiir xwrite /tag/sel/ctl send sel left
Key $MODKEY-Shift-$RIGHT # Move selected client to the right
wmiir xwrite /tag/sel/ctl send sel right
Key $MODKEY-Shift-$UP # Move selected client up
wmiir xwrite /tag/sel/ctl send sel up
Key $MODKEY-Shift-$DOWN # Move selected client down
wmiir xwrite /tag/sel/ctl send sel down
Key $MODKEY-Shift-space # Toggle selected client between floating and managed layers
wmiir xwrite /tag/sel/ctl send sel toggle
KeyGroup Client actions
Key $MODKEY-f # Toggle selected client's fullsceen state
wmiir xwrite /client/sel/ctl Fullscreen toggle
Key $MODKEY-Shift-c # Close client
wmiir xwrite /client/sel/ctl kill
KeyGroup Changing column modes
Key $MODKEY-d # Set column to default mode
wmiir xwrite /tag/sel/ctl colmode sel default-max
Key $MODKEY-s # Set column to stack mode
wmiir xwrite /tag/sel/ctl colmode sel stack-max
Key $MODKEY-m # Set column to max mode
wmiir xwrite /tag/sel/ctl colmode sel stack+max
KeyGroup Running programs
Key $MODKEY-a # Open wmii actions menu
action $(wi_actions | wimenu -h "${hist}.actions" -n $histnum) &
Key $MODKEY-p # Open program menu
eval wmiir setsid "$(wimenu -h "${hist}.progs" -n $histnum <$progsfile)" &
Key $MODKEY-Return # Launch a terminal
eval wmiir setsid $WMII_TERM &
KeyGroup Other
Key $MODKEY-Control-t # Toggle all other key bindings
case $(wmiir read /keys | wc -l | tr -d ' \t\n') in
0|1)
echo -n "$Keys" | wmiir write /keys
wmiir xwrite /ctl grabmod $MODKEY;;
wmiir xwrite /keys $MODKEY-Control-t
wmiir xwrite /ctl grabmod Mod3;;
esac
KeyGroup Tag actions
Key $MODKEY-t # Change to another tag
wmiir xwrite /ctl view $(wi_tags | wimenu -h "${hist}.tags" -n 50) &
Key $MODKEY-Shift-t # Retag the selected client
# Assumes left-to-right order of evaluation
wmiir xwrite /client/$(wi_selclient)/tags $(wi_tags | wimenu -h "${hist}.tags" -n 50) &
# for i in 0 1 2 3 4 5 6 7 8 9; do
# cat <<!
#Key $MODKEY-$i # Move to the numbered view
# wmiir xwrite /ctl view "$i"
#Key $MODKEY-Shift-$i # Retag selected client with the numbered tag
# wmiir xwrite /client/sel/tags "$i"
# done
Key $MODKEY-1
wmiir xwrite /ctl view "web"
Key $MODKEY-Shift-1
wmiir xwrite /client/sel/tags "web"
Key $MODKEY-2
wmiir xwrite /ctl view "ctrl"
Key $MODKEY-Shift-2
wmiir xwrite /client/sel/tags "ctrl"
Key $MODKEY-3
wmiir xwrite /ctl view "stat"
Key $MODKEY-Shift-3
wmiir xwrite /client/sel/tags "stat"
Key $MODKEY-4
wmiir xwrite /ctl view "msg"
Key $MODKEY-Shift-4
wmiir xwrite /client/sel/tags "msg"
Key $MODKEY-5
wmiir xwrite /ctl view "img"
Key $MODKEY-Shift-5
wmiir xwrite /client/sel/tags "img"
Key $MODKEY-6
wmiir xwrite /ctl view "vid"
Key $MODKEY-Shift-6
wmiir xwrite /client/sel/tags "vid"
Key $MODKEY-7
wmiir xwrite /ctl view "misc"
Key $MODKEY-Shift-7
wmiir xwrite /client/sel/tags "misc"
Key $MODKEY-8
wmiir xwrite /ctl view "misc1"
Key $MODKEY-Shift-8
wmiir xwrite /client/sel/tags "misc1"
Key $MODKEY-9
wmiir xwrite /ctl view "misc2"
Key $MODKEY-Shift-9
wmiir xwrite /client/sel/tags "misc2"
Key $MODKEY-0
wmiir xwrite /ctl view "misc3"
Key $MODKEY-Shift-0
wmiir xwrite /client/sel/tags "misc3"
wi_events events local_events
# WM Configuration
wmiir write /ctl <<!
font $WMII_FONT
focuscolors $WMII_FOCUSCOLORS
normcolors $WMII_NORMCOLORS
grabmod $MODKEY
border 1
# Misc
progsfile="$(wmiir namespace)/.proglist"
action status &
wi_proglist $PATH >$progsfile &
wmiir xwrite /ctl "colmode default"
xsetroot -solid "$WMII_BACKGROUND" &
# Autostart (this is ghetto, i know)
echo -n view ctrl | wmiir write /ctl;urxvtc -e ssh 192.168.1.55 -p 228 &
urxvtc -e ssh [email protected] -p 228 &
sleep 1.5 && urxvtc &
sleep 2 && wmiir xwrite /tag/sel/ctl send sel right &
sleep 2.5 && echo -n view stat | wmiir write /ctl;urxvtc -e vifm &
sleep 2.5 && urxvtc -e alsamixer &
sleep 3 && urxvtc -e htop &
sleep 3.5 && wmiir xwrite /tag/sel/ctl send sel left &
sleep 4 && echo -n view msg | wmiir write /ctl;pidgin &
sleep 3.5 && echo -n view web | wmiir write /ctl;wmiir xwrite /tag/sel/ctl colmode sel stack;uzbl-browser &
# Setup Tag Bar
IFS="$wi_newline"
wmiir rm $(wmiir ls -p /lbar) >/dev/null
seltag=$(wmiir read /tag/sel/ctl | sed 1q)
unset IFS
wi_tags | while read tag
do
if [ "$tag" = "$seltag" ]; then
echo "$WMII_FOCUSCOLORS" "$tag"
else
echo "$WMII_NORMCOLORS" "$tag"
fi | wmiir create "/lbar/$tag"
done
wi_eventloop
Also I should mention this is wmii-hg. I like hg better then 3.9 because in 3.9 the columns are all screwed up.
I.E I like fixed column sizes where the right column is always smaller then the left no matter which side you move the client to. (difficult to explain)
Last edited by tjwoosta (2010-07-01 03:23:06)Mike,
You were close. Split returns an array, not a string.
// form1.page1.subform1.foo::exit - (JavaScript, client)
var wordCnt = new Array();
var str = this.rawValue;
wordCnt = str.split(" ");
xfa.host.messageBox("There are " + wordCnt.length + " words.");
Steve -
EEM / Tcl Script Help Please
Hello Community,
I have been evaluating a Tcl Script posted here sometime ago, designed to help monitor track interfaces and routes, see attached.
I believe I have applied the configurations correctly, however when I test the script by shutting down interfaces nothing happens.
I'm sure its something very simple that I'm missing.
I wonder if someone could take a look at the configs and let me know what I'm doing wrong. I have also attached a diagram.
Cheers
CarltonJoseph,
I did read again and I got it to work :-)
Cheers
On a slightly different topic, is it possible to 'track' a static ip address?
For example, I have the following tracking configured:
track 1 ip route 0.0.0.0 0.0.0.0 reachability
track 2 interface FastEthernet0/0 ip routing
track 3 interface FastEthernet0/1 ip routing
track 4 ip route 180.80.8.4 255.255.255.255 reachability
track 5 ip route 170.70.7.4 255.255.255.255 reachability
R3#show track brie
Track Object Parameter Value
1 ip route 0.0.0.0/0 reachability Up (static)
2 interface FastEthernet0/0 ip routing Up
3 interface FastEthernet0/1 ip routing Up
4 ip route 180.80.8.4/32 reachability Down (no route)
5 ip route 170.70.7.4/32 reachability Down (no route)
However, you will see that track 4 and 5 are down. This is because, although I can ping 180.80.8.4 and 170.70.7.4 the actual ip addresses don't appear in the routing table:
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
170.70.0.0/24 is subnetted, 1 subnets
C 170.70.7.0 is directly connected, FastEthernet0/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, FastEthernet1/0
180.80.0.0/24 is subnetted, 1 subnets
C 180.80.8.0 is directly connected, FastEthernet0/1
150.50.0.0/24 is subnetted, 1 subnets
C 150.50.5.0 is directly connected, Ethernet2/0
S* 0.0.0.0/0 is directly connected, FastEthernet1/0
R3#
Therefore, is there way of creating a track for /32 ip addresses?
I hope that makes sense.
Cheers -
Auto refresh with apple script- help please
can any one help me please
i use multiple windows in safari at one time and can any one help me to refresh these pages (two windows) automatically using apple script.
also if I click manually to refresh these pages i get the following note"
"To open this page again, Safari must resend the form you completed to open the page the first time. This may cause the website to repeat actions it took the first time you sent the form."
and i have click send for this to happen
any help from you all will be appreciated as this will help me a lot with the present work that i am doingNot sure about the "automatic" reload - Opera allows you to set a refresh time interval for each tab, but not Safari. Also, Safari Extender gives you a single click contextual menu option to "reload all tabs".
here is an AppleScript for a one-page auto reload. You might be able to alter the script to auto reload all open tabs.
Not sure about the "warning" message. Can you post a URL so I can have a look?
Maybe you are looking for
-
How do I sync my ipod touch with itunes 10.7 under windows 8?
It is already three weeks since I installed Windoes 8 on my computer, till now I haven't got any help from apple concerning the syncing problems of my Ipod touch. This is not very impressive. do I have to change my MP3 player and forget about Ipod?
-
Default Selection in Combo Box
Hi, I have a query regarding combo box. I have populated combo box using UserDataSources. Is it possible to make a default selection of an Item in combo box. Regards Ronald
-
Question: Is The Macbook right for me
i am thinking about getting a new laptop and i started to think about the macbook or macbook pro. i am a web programmer, i work with coldfusion and will start to work with mysql more. i not a really big gamer so that is not a big deal to me. i was ho
-
Foriegn Trade and CIN configuration for SD
Hi all, Can anybody please send me step by step procedures regarding 1. Foriegn trade configuration in SD Module wrt India. 2. CIN configuration in SD Module. Regards, Khan
-
We connect fine to another Oracle database via DSN. However, when attempting to connect to a different database using a Driver={} and a dbq="" reference to specify the service name (which matches in tnsnames.ora), the ODBC Dialog Box appears and chal