Script for time stamp update.

scmuser created the topic: Script for time stamp update.

write a batch Script for time stamp update?

sgadmin replied the topic: Re:Script for time stamp update.

data=data.txt
tfile=`cat data.txt |wc -l`


for (( i = 2 ; i <= tfile ; i++ ))
do

mfile=`cat $data |head -$i|tail -1|tr -s ” ” ” ” |cut -f8 -d” “`
mdate=`grep -i $mfile $data|tr -s ” ” ” “|cut -f6,7 -d” “`
myy=`echo $mdate |cut -b 1-4`
mon=`echo $mdate |cut -b 6-7`
mdd=`echo $mdate |cut -b 9-10`
mhh=`echo $mdate |cut -b 12-13`
mmin=`echo $mdate |cut -b 15-16`
mresult=`echo $myy$mon$mdd$mhh$mmin`
touch -t $mresult $mfile

done

Tagged :

%~dp0 VS %cd%

rajeshkumar created the topic: %~dp0 VS %cd%

Use of %~dp0 and Use of %cd%

They are not equivalent.

%cd% is available either to a batch file or at the command prompt and expands to the drive letter and path of the current directory (which can change e.g. by using the CD command)

%~dp0 is only available within a batch file and expands to the drive letter and path in which that batch file is located (which cannot change). It is obtained from %0 which is the batch file’s name.

An experiment like the following shows the difference

Here is D:\dirshow.bat:

@echo off
echo this is %%cd%% %cd%
echo this is %%~dp0 %~dp0

Run it from C:\ and this is what you see

C:\>D:\dirshow.bat
this is %cd% C:\
this is %~dp0 D:\

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Send mail using batch script thorugh SMTP

scmuser created the topic: Send mail using batch script thorugh SMTP

Hello,
hi i wnt to create batch file that will automtcally send my email through outlok express at 5 pm daily with the attachement.
if anybody has any idea about this plz write to me
help would be appreciated.

Tagged :

DOS Command to display time without prompting for New time

scmuser created the topic: DOS Command to display time without prompting for New time

I think most of us know the DOS command “time/T” which displays current system time without prompting for new time.

But If one needs more granular output, say in HH:MM:SS format, here is a way out, use “echo %TIME%” which expands to current time using same format as TIME command.

There are so many other things which can be echoed. For example, try any of the following variables:
%CD% – expands to the current directory string.

%DATE% – expands to current date using same format as DATE command.

%RANDOM% – expands to a random decimal number between 0 and 32767.

%ERRORLEVEL% – expands to the current ERRORLEVEL value

%CMDEXTVERSION% – expands to the current Command Processor Extensions version number.

%CMDCMDLINE% – expands to the original command line that invoked the Command Processor.

%PATH% – expands the current PATH variable.

Tagged :

Call perl script from vbscript

rajeshkumar created the topic: Call perl script from vbscript

Call perl script from vbscript

Set oShell = CreateObject("WScript.Shell")
sProgDir = "C:\Program Files\My Programs\perl\"
sArgs = "-i"
sExec = """" & sProgDir & "myperl.pl" & """"
sCmd = sExec & " " & sArgs
oShell.Run(sCmd)

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Call batch script from vbscript

rajeshkumar created the topic: call batch script from vbscript

Call batch script from vbscript

dim shell
set shell=createobject("wscript.shell")
shell.run "INSTALL.bat"
set shell=nothing

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

How to run scripts as administrator in Windows using VBS?

rajeshkumar created the topic: How to run scripts as administrator in Windows using VBS?

How to run scripts as administrator in Windows using VBS?

Set WshShell = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.length = 0
Then
Set ObjShell = CreateObject("Shell.Application")
ObjShell.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" &_
" RunAsAdministrator", , "runas", 1
Else

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

How to Run a Program as an Administrator in Windows

rajeshkumar created the topic: How to Run a Program as an Administrator in Windows

How to Run a Program as an Administrator in Windows

Good URL-
www.sevenforums.com/tutorials/11841-run-administrator.html

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Function in vb script

rajani created the topic: function in vb script

Develop a function that accepts a string of names separated by comma add those names in an array and display the names added in the array.

rajeshkumar replied the topic: function in vb script

Welcome to board….

try following snippet…

Sub Funstr("str1", "str2")

a=Array(str1,str2)
document.write(a(0))
document.write(a(1))
End Sub

I would recommend you going through this url as well to learn more about it……

www.functionx.com/vbscript/Lesson06.htm

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajani replied the topic: function in vb script

it won’t work
i have write
“Develop a function that accepts a string of names separated by comma (example given below), add those names in an array and display the names added in the array”

Example: rajani; Disha; Dhara; Hunny ;moon
without using split function
can i use mid function

rajani replied the topic: function in vb script

i am able to display name but with comma
Dim fruits()
ReDim fruits(100)
nofruits=0
‘we do not know how many fruit names we are going to enter and so, we have declared the array size as 100
For i=0 to 100
fruits(i)=inputbox(“Enter the name of a fruit separated by comma”)
ans = MsgBox(“Do you want to continue”, vbYesNo, “Confirm Continuation…”)
If ans=vbNo Then
Exit For
End If
nofruits=nofruits+1
Next
ReDim Preserve fruits(nofruits)
‘Redim keyword resets the number of elements that can be accommodated in the array.

fruitnames=””

For each fruit in fruits
‘Using For Each Next we have displayed all the names of the fruits which was entered and kept in fruits array.
‘For Each Next extracts the fruit names stored in the array and msgbox displays the output.

fruitnames=fruitnames&fruit&vbnewline
Next

msgbox fruitnames

rajani replied the topic: function in vb script

any suggestion

rajani replied the topic: function in vb script

dim Array, Str1,X
Str1 = “Neha; Swati; Disha; Sonya; Dhara”
Array = split(Str1,”;”)
for each x in Array
message = message & x & vbCRLF
next
msgbox message

Tagged :