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 :

Check the exit code of the last command in batch file?

rajeshkumar created the topic: check the exit code of the last command in batch file?

Test for a return code greater than or equal to 1:

if ERRORLEVEL 1 echo Error
or

if %ERRORLEVEL% GEQ 1 echo Error

or test for a return code equal to 0:

if %ERRORLEVEL% EQU 0 echo OK

You can use other commands such as GOTO where I show echo
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Get the application exit code from a Windows command line?

rajeshkumar created the topic: get the application exit code from a Windows command line?

Two ways…

(1) The results are stored in a pseudo environment variable named errorlevel so…

echo Exit Code is %errorlevel%
(2) and a special syntax of the if command:

if errorlevel
see if /? for details.

For Example

@echo off
my_nify_exe.exe
if errorlevel 1 (
echo Failure Reason Given is %errorlevel%
exit /b %errorlevel%
)
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: get the application exit code from a Windows command line?

:: Exit if a required file is missing
@echo off
If not exist MyimportantFile.txt Exit /b
Echo If we get this far the file was found

:: Set the error level to 5
@echo off
call :setError
echo %errorlevel%
goto :eof

:setError
Exit /B 5

To make this more flexible you can change the subroutine to set any errorlevel like this:

:setError
Exit /B %1

Now you can call the subroutine: call :setError 6 replacing 6 with whatever value you need the errorlevel to be set to.

EXIT is an internal command.
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Useful Command for Process and Jobs in Unix/Linux

rajeshkumar created the topic: Useful Command for Process and Jobs in Unix/Linux

List out all background Job running in machine i.e. list current jobs
> jobs

How to sent Job into Background ie background the suspended job
> bg

How to run background jobs on foreground

1. Find out the job number using “jobs” command
2. Type follwoing fg %jobnumber

Whats the differnce between control c and control z in Linux

^C – kill the job running in the foreground
^Z – suspend the job running in the foreground

To kill a suspended or background process
> kill %jobnumber

To kill a job running in the foreground
> sleep 100
^C

List out all background job running by each user
ps -u

To see every process on the system using standard syntax:
> ps -ef

To see every process on the system using BSD syntax:
> ps ax

To print a process tree:
> ps -ejH

To get info about threads:
> ps -eLf

To see every process running as root (real & effective ID) in user format:
> ps -U root -u root u
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Find command return type

scmuser created the topic: Find command return type
I am looking for following answer if anybody can help me out…

How to Return a message when a file is not found using find command? OR
Find command return type OR
when the file is not found i want it to return some value OR

tpatil replied the topic: Re: Find command return type
You can use exit code of find command to return the message.

e..g.

find . -name abc.txt > dev/null

if test $? -eq 0
then
echo "File found"
else
echo "File Not Found"
fi

Hope this helps…

rajeshkumar replied the topic: Re: Find command return type
Hi..

I guess following script will not work. The problem here is find command does always return true value no matter if find is available or not.

this is unique things in find command.

I feel we should go ahead in this way.

find . -name raj.txt > raj.txt
counter= `cat abc.txt | wc -l'

if [$counter -gt 0]
then
echo "File is found"
else
echo "File is not found"
fi

please let us your inputs on this
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

tpatil replied the topic: Re: Find command return type
Thanks Rajesh…You are right. I tried with my code. Find always retuns 0 though file not found.

Tagged :

Expect command in unix /linux?

scmuser created the topic: expect command in unix /linux?
Hello,
I am doing a project which asks me to enter password 4 times in a row. I need to enter the same password 4 times. My target is to enter password once and apply it 4 times.
My friend told me to use “expect” command. Can you please give me a sample code to do so.

sample command :- $ ssh @(like :ssh root@127.0.0.1)
enter ‘s password:

Could somebody plz tell me where the command “expect” is used. and wud appreciate if you can write a simple standalone script that uses this command. thanks

rajeshkumar replied the topic: Re: expect command in unix /linux?

Tagged :

How to find success/failure status of a command in different shells?

rajeshkumar created the topic: How to find success/failure status of a command in different shells?

Ksh/Borne/Bash shell
$ ls /usr/bin
….
# when success value is 0
$ echo $?
0
$ ls /usr/bin/blah
ls: 0653-341 The file /usr/bin/blah does not exist
# when failure non-zero status
$ echo $?
1

c/Tcsh
$ ls /usr/bin
….
# when success value is 0
$ echo $status
0
$ ls /usr/bin/blah
ls: 0653-341 The file /usr/bin/blah does not exist
# when failure non-zero status
$ echo $status
1

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

Tagged :

Run CreateInstall from the command line

created the topic: Run CreateInstall from the command line? Goto page 1, 2 Next
Hi,

I am wondering if it is possible to use CreateInstall to create an installer package from the command line (according to a specific .ci file).

This way I could create a package using a cmd file. Making the package could be done automatically ….. from a script of mine. Idea

applicationPackaging replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
Yes, you can.

ci.exe

For example

ci.exe “c:\my setups\my.ci”
ci-light.exe c:\temp\my.ci
_________________

replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
ow I am wondering if there is a switch that would suppress the “Creating Installation” Dialog ?

If not, maybe “we” could add this feature in the future? —- Wink

applicationPackaging replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
There is not such feature.
The state of checkboxes is the same as in the previous execution.

replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
Hi,

Before I was Running ci.exe from the command line according to a specific .ci file

I ran from vbscript [ci.exe “File.ci”] it in a hidden window, I still saw the Build Dialog. But I did not see the ci.exe main window.

In CI5 is there a way?
How about cicmd.exe ?

Does ci.exe have any undocumented switches?

I would at the very least like to run from a .cmd file without the Main window and see just the Build Dialog like I can do using vbscript.

I am trying to automate the Packaging operation. I would like it to be Totally quiet, and at the most see the Build Dialog.

I would like to do this without using vbscript.

Any hope for me? Rolling Eyes Rolling Eyes

I noticed if I make an XP shortcut to ci.exe, and in the properties window choose Run Minimized.

Then if you double click the shortcut, ci.exe does Not run minimized. So I cannot use this as a workaround.

applicationPackaging replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
If you want to run creating setups from the command line then use cicmd.exe

cicmd.exe “path to your .ci project file”
Also, see Project tab – > Setup Builder options of your project.

About minimizing shotrcuts
Open cmds\cmds\system\shortcut.gt
Change Line 91 from
2
to
7

Save it. It will fix the problem.

applicationPackaging replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
Great,

cicmd.exe let me run the ci file with the main window minimized.
I only see the Build Dialog Box.

That was a big help.

Alexey I have a cmd script that is parsing and writing the *.ci file.
At the end of the .cmd file, I run the file now using cicmd.exe.

It would really be nice to be able to suppress the Build Dialog.

In my .cmd file I want to parse and create the .ci file, then Build the CreateInstall.exe file.

Then I would like to go on without stopping in my .cmd file, and parse a new *.ci file, and then create a new Installerexe file then perhaps repeat again more times!

But I cannot do this as when I run cicmd.exe the first time, the Build Dialog Opens and I have to close it.

Though I would MUCH prefer to be able to suppress the Build Dialog when using cicmd.exe , I could get by if the Dialog would open then close automatically.

In CI5, checking the box in the Build Dialog for “Close Automatically On Completion” seems to do nothing (even for a re-build).

Help! (a little bit more) Smile

replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
For example, you have a project myproject.ci.
Open it with ci.exe
Open Project Tab – Setup Builder.
Check on ‘Close Automatically’ checkbox there.
Save it.
Now if you run it as
cicmd.exe myproject.ci
then Build Dialog will be closed automatically.

applicationPackaging replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
This may be true, but I never will use cicmd.exe on a .ci file that has been run by double clicking (thru the main window).

So When I run a .ci file with cicmd.exe, a .ci file that has never been run …… when I check the box “Close Automatically” then hit the button “Close”…. (here there is no way to “save”) .

For a new .ci file, the box is always unchecked by default.

I need a preference setting to choose cicmd.exe to always close automatically (for the next time I run a new file with cicmd.exe)

Always on a .ci file never Built, the box is unchecked.
Am I wrong?

replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
You can manage the state of checkboxes from the command line.
-r or -r1 – ‘Launch setup on close’ is checked
-r0 – unchecked
-c or -c1 – ‘Close Automatically’ is checked
-c0 – unchecked

For example,
cicmd.exe -c -r “myproject.ci”

applicationPackaging replied the topic: Re: Run CreateInstall from the command line? Goto page 1, 2 Next
Just what I needed !

That -c1 switch is just “what the Doctor ordered” !

That works and allows me to do what I wanted to do.

Smile Smile Smile Very Happy Very Happy Very Happy Very Happy Very Happy

Thanks for doing such a good job understanding what I wanted to do.
Once again CreateInstall comes thru, and has the power to solve my problem to my perfect satisfaction.

This is rare in the world of software, and I say these things because I am fussy: it seems like I am always wanting to do something the software cannot do.

Also the time it takes to get answers in this forum is super short. Anyone reading this post Knows that real answers do not come quickly in the forums elsewhere on other subjects! I KNOW !!!!!!

All of this represents a level of quality, I for one, only aspire to !
Report This
Quick Reply Action Moderate Thank You

Tagged :