Page 1 of 2 12>
Topic Options
#111739 - 2004-01-13 08:15 PM Suppress Return Codes
bobx Offline
Fresh Scripter

Registered: 2004-01-04
Posts: 15
Hi there,

i have a Kix-Loginscript running with lots of COPY and USE commands etc.
In the script window, behind or sometimes even inbetween my status messages
( e.g. "successfully copyied" ) there are always a few numbers, mostly "0" but
somtimes "2000" etc.
I dont know where there are coming from, i assume these are the return-codes of the
particular commands. How can i get rid of them?

thanks and greetings,

rob

Top
#111740 - 2004-01-13 08:34 PM Re: Suppress Return Codes
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See the FAQ Forum under Why does the console display zeros and ones (amongst others)?
_________________________
There are two types of vessels, submarines and targets.

Top
#111741 - 2004-01-13 08:34 PM Re: Suppress Return Codes
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

See topic Why does the console display zeros and ones (amongst others)?
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#111742 - 2004-01-13 08:35 PM Re: Suppress Return Codes
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Please read through the KiXtart >> KiXtart FAQ & How to's forum. Specially: Suppressing Results when running
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#111743 - 2004-01-13 08:39 PM Re: Suppress Return Codes
bobx Offline
Fresh Scripter

Registered: 2004-01-04
Posts: 15
ok ok, stop please. Im just reading it...

thanks,

rob

Top
#111744 - 2004-01-13 08:52 PM Re: Suppress Return Codes
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
looking at the reply posting times, seems like we have couple of persons that have way too much free time to hang for opportunity to post and help
_________________________
!

download KiXnet

Top
#111745 - 2004-01-13 09:04 PM Re: Suppress Return Codes
bobx Offline
Fresh Scripter

Registered: 2004-01-04
Posts: 15
that may be so , but anyway its great that you people care to help!

and it just happens that i have an additional problem:
i read the links above (twice!), but when i add an "$RC=" in front of my
commands (doesent matter if COPY or USE or SHELL) i always get an
"ERROR IN EXPRESSION" in the particular line.

greetings,
rob

Top
#111746 - 2004-01-13 09:07 PM Re: Suppress Return Codes
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Please post your code for review. "$RC= copy" is not valid.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#111747 - 2004-01-13 09:16 PM Re: Suppress Return Codes
bobx Offline
Fresh Scripter

Registered: 2004-01-04
Posts: 15
its a huge script, and the remarks are in german, but here it is:
i added a few "$RC="s in the bootom part after the "saplogon.ini"-part.

Code:
 
; ....................................................................
; Kixtart2001(v4.22) Script
; Logonskript
; Version 0.91 // 13.01.2004 // RD
; ....................................................................



; ...Begruessung
; ....................................................................
SetConsole ("MAXIMIZE") ; Konsolenfenster anzeigen
Box (0,0,15,55,"double")

At (2,12) " - Helios Klinik - "
At (4,3) "Willkommen @userid!"
At (6,3) "Es ist @time Uhr."
At (7,3) "Sie sind angemeldet an %logonserver%."
At (8,3) "Ihr Homedrive ist %homedrive%."
At (9,3) "Ihre IP-Adresse lautet @ipaddress0"
At (10,3) "Ihre primaere Gruppe ist: @PRIMARYGROUP"
At (11,3) "Sie sind zur Zeit berechtigt als: @priv"
At (12,3) "Ihr Passwort wurde zuletzt vor @PWAGE Tagen geaendert."
At (18,0) ?

sleep 2

; ... Variablenzuordnung
; ....................................................................

$logonuser="/user:king\%username%"
$errnum=0 ; Fehlerzähler für Ausgabe ins Eventlog
$tss=0 ; Terminalserversession (1/0 = Ja/Nein)
$err=0
$succ=0 ; Mappen des Gruppenverzeichnisses erfolgreich (1/0 = Ja/Nein)
;$confpath="C:\GSD\wup_lokal\Novell Migration\Logonscript\Neu\netlogon-share\config" ; TESTPFAD!
;$toolpath="C:\GSD\wup_lokal\Novell Migration\Logonscript\Neu\netlogon-share\tools" ; TESTPFAD!
$confpath="%logonserver%\netlogon\config" ;Pfad zu den Config-Dateien
$toolpath="%logonserver%\netlogon\tools" ; Pfad zu den Loginscript-tools

; ... Eventlog- und Fehlermeldungen
$ev1 = "Fehler beim Oeffnen der groups_and_dirs.ini Suchpfad war: $confpath\groups_and_dirs.ini"
$ev2 = "Gruppenlaufwerk konnte nicht gemappt werden Benutzer ist keiner Benutzergruppe zugeordnet oder primaere Gruppe wurde nicht korrekt gesetzt! Primaere Gruppe des Users: @PRIMARYGROUP"
$ev3 = "Fehler beim Mappen des Gruppenlaufwerks Es wurde versucht m: auf \\$orga\$groupdir zu verbinden"
$ev4 = "Fehler beim Kopieren der Kodib - Datenbank von %logonserver%\netlogon\config\faelle2.mdb nach %HOMEDRIVE%%HOMEPATH%\windows "
$ev5 = "Fehler beim Kopieren der Datei 'sql.ini' von %logonserver%\netlogon\config\sql.ini nach %HOMEDRIVE%\windows"
$ev6 = "Fehler beim Kopieren der Datei saplogon.ini von %logonserver%\netlogon\config\saplogon.ini nach %HOMEDRIVE%\windows"
$ev7 = "Fehler Verbinden von N: auf \\KW-Verwaltung Fehler trat beim Ausfuehren des USE-Befehls (wie NET USE) auf."
$ev8 = "Fehler Verbinden von O: auf \\KW-Kliniken Fehler trat beim Ausfuehren des USE-Befehls (wie NET USE) auf."
$ev9 = "Fehler beim erstellen von Outlook-Profil Fehler trat beim Aufruf von %LOGONSERVER%\netlogon\tools\newprof.exe und %LOGONSERVER%\netlogon\config\outlook.prf auf."
$ev10 = "Fehler Verbinden von com1: auf \\client\com1"
$ev11 = "Fehler Anlegen oder Kopieren des KV-Ordners Fehler trat beim Anlegen des KV-Ordners in L: auf oder beim Kopieren der KV-Dateien auf."
$ev12 = "Fehler in Sektion :apps bei Befehl: Schreiben des aktuellen Clientnames in die sql.ini "
$ev13 = "Fehler in Sektion :apps bei Befehl: Setzen der Display-Variable fuer Orga und SAP "
$ev14 = "Fehler in Sektion :apps bei Befehl: Setzen der IE - Option FriendlyHttpErrors auf NO "
$ev15 = "Fehler in Sektion :apps bei Befehl: Aktivierung von TLS 1.0 im IE fuer den zugriff auf geschuetze bereiche "
$ev16 = "Fehler beim erstellen der newprof.txt Pfad war USERPROFILE%\Newprof.txt"
$ev17 = "Fehler beim Eintragen der Outlook.reg in die Registry."
$ev99 = "Das Logonscript wurde fehlerfrei ausgeführt."

; ..Terminalserversession abfragen / Ja=1/Nein=0
If InGroup ("TERMINALSERVERBENUTZER")
$tss=1
Color b+/n ? "Dies ist eine Terminalserversession." ? Color w/n
Else
$tss=0
EndIf

; ... allgemeine Befehle
; ...
Break ON ; Break OFF bewirkt, das beim absichtlichen Abbrechen des Scriptes der User automatisch abgemeldet wird
; settime "\\servername" ;synchronisiert die lokale Zeit mit Server oder Domaene



; ... Benutzer- und gruppenspezifische Pfade
; ....................................................................

; Einlesen der existierenden AD-Gruppen und der Gruppenverzeichnisse
; und Mappen bei Uebereinstimmung
; ...

; Oeffnen der groups_and_dirs.ini-Datei
If Open(2, "$confpath\groups_and_dirs.ini") = 0
While @ERROR = 0

; Einlesen der ini-datei und Aufbereiten der Daten
$grpstring = ReadLine(2) ; auslesen einer Zeile der ini-Datei
$grpstring = Trim($grpstring) ; vorhandene Leerzeichen loeschen
If $grpstring = "ende" GoTo weiter EndIf

$grparray = Split ($grpstring,",",3) ; Zeile in Bestandteile zerlegen
$group = $grparray[0]
$groupdir = $grparray[1]
If $grparray[2] = "v" $orga = "kw-verwaltung" Else $orga = "kw-kliniken" EndIf

; Ausgabe der eingelesenen Variablen (zu Testzwecken)
; ? "Prim.Gruppe: @PRIMARYGROUP | akt.Gruppe: $group | Dir: \\$orga\$groupdir"

; Primaere Gruppe abfragen und bei Uebereinstimmung Verzeichnis mappen
If $group = @PRIMARYGROUP
Use m: "\\$orga\$groupdir"
If @ERROR
ermes($ev3) ;Funktion 'ermes' aufrufen, siehe Scriptende fuer Erlaeuterung
GoTo weiter
Else
? "\\$orga\$groupdir auf M: verbunden."
EndIf
$succ=1
GoTo weiter
EndIf
Loop
Else
ermes($ev1)
GoTo allgmap
EndIf

:weiter
? Close (2) ; ini-Datei schliessen
If $succ=0 ermes($ev2) EndIf

:allgmap
; .. Allgemeine Verzeichnismappings
; ..
Use N: "\\KW-Verwaltung\verwaltung" $logonuser
If @ERROR ermes($ev7) Else ? "Laufwerk N: verbunden." EndIf

Use O: "\\KW-Kliniken\kliniken" $logonuser
If @ERROR ermes($ev8) Else ? "Laufwerk N: verbunden." EndIf



; ... Anwendungspezifische Befehle:
; .............................................................

; .. Windows-Verzeichniss bei Bedarf anlegen
; ..
If Exist ("%homedrive%\windows")=0
MD "%homedrive%\WINDOWS"
EndIf

; .. Userspezifische Kodip DB erzeugen, wenn sie nicht im Userhome Verzeichnis existiert
; ..
If Exist ("%HOMEDRIVE%%HOMEPATH%windows\faelle2.mdb")
? "Userspezifische Kodib DB ist vorhanden."
Else
Copy "$confpath\faelle2.mdb" "%HOMEDRIVE%%HOMEPATH%\windows\" /h
If @ERROR ermes($ev4) Else ? "Kodib-DB -kopiert." EndIf
EndIf

; .. Loeschen der SQL.INI im User Home
; .. und Kopieren der aktuellen SQL.INI
; ..
Del "%HOMEDRIVE%\windows\sql.ini"
Copy "$confpath\sql.ini" "%HOMEDRIVE%\windows\" /h
If @ERROR ermes($ev5) Else ? "sql.ini kopiert." EndIf

; .. Anlegen des KV Ordners und Kopieren der Dateien fuer ORGA KVK-Geraete
; ..
;Shell '%comspec% /c xcopy "%logonserver%\netlogon\config\KV" "%homedrive%\" /S /E /Y /I'
If Exist ("%homedrive%\KV")=0
MD "%homedrive%\KV"
If @ERROR ermes($ev11) Else ? "Kv-Ordner angelegt." EndIf
EndIf
Copy "$confpath\KV\*.*" "%homedrive%\KV\*.*" /h
If @ERROR ermes($ev11) Else ? "KV-Dateien kopiert." EndIf

; .. Kopieren der SAPlogon.ini
; ..
$RC = Copy "$confpath\saplogon.ini" "%HOMEDRIVE%\windows\"
If @ERROR ermes($ev6) Else ? "saplogon.ini kopiert." ? EndIf




:apps
; ...Eintragen der User und Geraete spezifischen Eintraege In der SQL.INI und der Registry
; .................................................................................................

; ... TS-Session ?
If $tss=0 ? "keine TS-Session." GoTo IEOPT EndIf ; folgendes nur bei Terminalserversession ausführen

; .. Mappt das ORGA Lesegeraet an COM1
If Exist ("com1:")=1
$RC = Shell '%comspec% /c net use com1: /delete'
EndIf
$RC = Shell '%comspec% /c net use com1: \\client\com1:'
If @ERROR ermes($ev10) else ? "Com1 wurde verbunden." EndIf

;Schreiben des aktuellen Clientnames in die sql.ini
WriteProfileString ("%HOMEDRIVE%\windows\sql.ini","win32client","clientname",%CLIENTNAME%)
If @ERROR ermes($ev12) Else ? "Clientname in sql.ini geschrieben." EndIf

;Setzen der Display-Variable fuer Orga und SAP
Set ("DISPLAY=%clientname%")
If @ERROR ermes($ev13) Else ? "Variable DISPLAY gesetzt." EndIf

; ...neues Outlook Profil anlegen
$RC = Shell "regedit /s " + $confpath + "\Outlook.reg"
If @ERROR ermes($ev17) Else ? "Outlook.reg eingelesen." EndIf

If Exist ("%USERPROFILE%\Newprof.txt")=1 GoTo ieopt EndIf
? "Neues Outlookprofil wird erstellt."
$RC = Shell $toolpath + "\newprof.exe -P " + $confpath + "\outlook.prf"
If @ERROR ermes($ev9) GoTo ieopt Else ? "Neues Profil wurde erstellt." EndIf
$RC = Open (3,"%USERPROFILE%\Newprof.txt",5) WriteLine (3,"Neues Profil erstellt am (Jahr/Monat/Tag): @date .") Close(3)
If @ERROR ermes($ev16) Else ? "Newprof.txt angelegt." EndIf


:IEOPT
;Setzen der IE - Option FriendlyHttpErrors auf NO
$RC = WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Friendly http errors","no","Reg_SZ")
If @ERROR ermes($ev14) Else ? "IE-Regkey 1 gesetzt." EndIf

;Aktivierung von TLS 1.0 im IE fuer den zugriff auf geschuetze bereiche
$RC = WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","SecureProtocols","168","reg_dword")
If @ERROR ermes($ev15) else ? "IE-Regkey 2 gesetzt." EndIf


:end
; ...Scriptende
; ..............
If $ernr >= 1 ; wenn Fehlernummer größer 0, Script für 3 sec Anhalten damit Fehler gesehen werden
Beep Sleep 3
Else
If $tss = 0
LogEvent (0,100,$ev99,"","Logonscript")
Else
LogEvent (0,100,$ev99,"%CLIENTNAME%","Logonscript")
EndIf
EndIf

If KBHit () ; wenn Taste "a" gedrueckt wird, script anhalten
Get $key
If $key = "a" ?? "Angehalten. Taste druecken zum fortfahren..." Get $key EndIf
EndIf

? "taste druecken..." Get $taste ; zu Testzwecken
Exit



; ...Anhang
; ...Funktion definieren: 'ermes' = Fehlermeldung fuer Ausgabe im Scriptfenster kuerzen und Ausgeben

Function ermes($errvar)
$ernr = $ernr + 1 ;Fehlerzähler um 1 erhöhen
$message = Left("$errvar", 44) + "- siehe Eventlog! " ;Fehlermeldung kuerzen
Color y+/n ? "$message" Color w/n ;Ausgabe kurze Fehlermeldung im Scriptfenster
If $tss = 0
$x = LogEvent (1,$ernr,"$errvar","","Logonscript") ;Ausgabe lange Fehlermeldung im Eventlog
Else
$x = LogEvent (1,$ernr,"$errvar","%CLIENTNAME%","Logonscript") ;für TS-Session (Meldungen werden ins lokale Eventlog geschrieben)
EndIf
EndFunction





greetings, rob

Top
#111748 - 2004-01-13 09:18 PM Re: Suppress Return Codes
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... I never said to put any such thing in front of commands. I only mention functions, not commands.

If you re-read my FAQ, you would see that I say:
Quote:

that they are the return codes from functions.


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#111749 - 2004-01-13 09:24 PM Re: Suppress Return Codes
bobx Offline
Fresh Scripter

Registered: 2004-01-04
Posts: 15
mhm.. i must have overlooked that difference.
no way of gettng rid of the returncodes from the commands?
( especially the returnmessage from the SHELL commands bothers me)

rob

Top
#111750 - 2004-01-13 09:30 PM Re: Suppress Return Codes
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Shell does not return anything. If SHELL outputs anything to the screen than it is the program you passed to SHELL that is outputing to the screen. If that is the case then you will have to employ using the ">nul" on your command line.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#111751 - 2004-01-13 09:32 PM Re: Suppress Return Codes
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Commands do not return codes. SHELL does not return any codes, either. However, stuff executed within the SHELL command could output to the console which would be suppressed by redirecting the output to >NUL.

Also, .INI files should always be read via READPROFILESTRING!

Finally, the use of GOTOs is frowned upon, so please get rid of them.
_________________________
There are two types of vessels, submarines and targets.

Top
#111752 - 2004-01-13 09:34 PM Re: Suppress Return Codes
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I see some WRITELINE's, and CLOSE's that need to be silenced.

Please see the manual as well as the FAQ. If the manual stated that the function returns a value then you need to catch it in a variable.

WriteLine( )

Action: Appends a line to the end of the file indicated by File Number. If WriteLine encounters an error, @ERROR is set to the relevant error code.

Syntax: WriteLine (FileHandle, “LineToWrite”)

Parameters: FileHandle
A numeric expression indicating the handle number of the file to open. Possible values range from 1 to 10.

LineToWrite

The string you want to write to the file.

Remarks: WriteLine does not automatically append a <Carriage Return> and <Line Feed>, so if you want to write this, you should add it to the string, as in: $LineToWrite + @CRLF.

Returns: -4 File not open for writing
-3 File number not open
-2 Invalid file number specified
-1 End of file
0 Line written successfully


See Also: Close( ), FreeFileHandle( ), Open( ), ReadLine( ), ReadProfileString( ), WriteProfileString( )

Example: IF Open( 3 , "C:\TEMP\LOG.TXT" , 5 ) = 0
$x = WriteLine( 3 , "KiXtart started at " + @TIME + @CRLF )
ELSE
BEEP
? "failed to open file, error code : [" + @ERROR + "]"
ENDIF



Edited by Howard Bullock (2004-01-13 09:39 PM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#111753 - 2004-01-13 09:35 PM Re: Suppress Return Codes
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
...which brings to mind another FAQ.
Not quite everything you wanted to know about RUN and SHELL
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#111754 - 2004-01-13 09:37 PM Re: Suppress Return Codes
bobx Offline
Fresh Scripter

Registered: 2004-01-04
Posts: 15
Quote:


Commands do not return codes. SHELL does not return any codes, either. However, stuff executed within the SHELL command could output to the console which would be suppressed by redirecting the output to >NUL.





hm its hard too see where the codes come from, but i will see...

Quote:

Also, .INI files should always be read via READPROFILESTRING!



why is that? my code works perfectly, its fast and i get the result i want.

Quote:

Finally, the use of GOTOs is frowned upon, so please get rid of them.



Why?

apart from that, please be gentle with me, i just learned kix a week ago and wrote this script.:)
greetings, rob

Top
#111755 - 2004-01-13 10:02 PM Re: Suppress Return Codes
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
.INI files employ a special file structure based on sections, keys, and values. See the KiXtart Manual for details under READPROFILESTRING/WRITEPROFILESTRING. Example:
Code:

[section 1]
key1=value1
key2=value2
[seciton2]
key1=value2



Search this BBS for threads discussion why not to use GOTOs. Basically, they mess up the program flow (and internal stacks) and have adverse effects when used in conjunction with e.g. subroutines and functions.
_________________________
There are two types of vessels, submarines and targets.

Top
#111756 - 2004-01-13 10:08 PM Re: Suppress Return Codes
bobx Offline
Fresh Scripter

Registered: 2004-01-04
Posts: 15
Quote:



.INI files employ a special file structure based on sections, keys, and values. See the KiXtart Manual for details under READPROFILESTRING/WRITEPROFILESTRING. Example:
Code:
[section 1]
key1=value1
key2=value2





yeah i read that, but my .ini is automatically generated in the format "group,dir,orga" so i saw no other way
than to use the readline-command.

however, thanks for all the help. i got rid of mostly all codes.

rob

Top
#111757 - 2004-01-13 10:19 PM Re: Suppress Return Codes
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Then it is not a .INI file and therefore should not have that particular extension.
_________________________
There are two types of vessels, submarines and targets.

Top
#111758 - 2004-01-13 10:32 PM Re: Suppress Return Codes
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens, I wouldn't go that far.
although it might be semi-standard what ini-file should contain, it's not a law.
ini mostly stands for initialization and already it is wide concept enough to let it be.

talking about ini-files is little different than talking about initialization or information files having ini-extension.

my 1 euro cent (2 americans)
_________________________
!

download KiXnet

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 363 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.051 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org