7-Zip command-line switch [closed] - 7zip

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Is there a 7-Zip command-line switch that prevents the filenames from echoing to the screen as they are added to the archive?

Not built in, but if you add
<7z command here> 2>&1 NUL
to the end of your command-line, it will redirect all the output into the null device and stops it echoing to the screen. This is the MS-DOS equivalent of
2>&1 /dev/null
in Linux and Unix systems.

7-Zip has no switch for this. If you are using PowerShell to call 7-Zip, you can redirect the output to null using Out-Null. For example,
C:\PS>my-create-7zip-function | out-null

If it doesn't have one, you can still redirect the output using > into a file, then deleting the file afterwards. If you are on *nix, you can redirect into /dev/null.
Edit
In MS-DOS and cmd.exe you can redirect into NUL, instead of a file. Thanks to agnul for this hint.

AFAIK, there is not a switch for that, but you could hide the output redirecting it to a file, for example (DOS batch):
7z.exe ... normal parameters > DumpFile.txt
This way all the output ends in DumpFile.txt and not on the screen.

To avoid file names echoing on the screen and display only the confirmations, do:
...\right_path\7z a output.zip folder_to_be_compressed | findstr /b /r /c:"\<Everything is Ok" /c:"\<Scanning" /c:"\<Creating archive"

Related

search string and replace corresponding number in windows env [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have one file and replace string :
sample file is:
DP_SESSION_ID is a sting for values
DP_SESSION_ID is aplicat
"DP_S42SETTACC_TYPE"\1\"02"
"DP_SAP_CLIENT"\1\"460"
"DP_SAP_COMM_CONNECTION"\1\"JAVA_COMM_TOOL_ANALYZER"
"DP_SAP_CONNECTION"\1\"JAVA_TOOL_ANALYZER"
"DP_SAP_TOOLBI_CONNECTION"\1\"JAVA_TOOLBI_ANALYZER"
"DP_SESSION_ID"\1\"808"
I want search this "DP_SESSION_ID"\1\" sting and replace corresponding number like 808 in file prenatally(windows env), and i wand sing line command in windows bat command or perl command i don't want scrip or program
even i have installed cygwin tool in my server so unix also ok but single line command
server: windows 2008,cygwin x
using tool : datastage server jobs
perl -pi -e 's{" "DP_SESSION_ID"\1\"808 '"}{' "DP_SESSION_ID"\1\"900 '"'"}g' " file name
this code is not working
Please give good solution
First, you can't use single-quotes in DOS the way you can in UNIX. Second, you need to specify a backup file/extension when you use "-i" in DOS. Third, I think you skip trying to match all those complicated quotes and go with a simpler approach. It may not be the most efficient (using 2 regex) but it's very readable (to me).
This works for me:
perl -p -i.bak -e "m/\"DP_SESSION_ID\"/ && s/808/900/g" "filename"
Hope that helps!
in powershell, you can try the command as below:
get-content input.txt |foreach-object {$_ -replace '"DP_SESSION_ID"\\1\\"808"', '"DP_SESSION_ID"\1\"900"'} | set-content output.txt

How to print output of ruby function to a file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have written a program in ruby. The output correspondng to which is really long, a couple of thousand lines.
Is there a way I can write this output to a file and not in the shell, because the shell allows you to scroll up only till a certain point? I know that I can use file.puts in place of puts. But, I want to know if there is a command using which I can achieve this without making changes in the program? For shell scripts we can do script.sh > output.txt. Similarly for a shell command as well. But what about a ruby program? It doesn't seem to be working.
The problem is that ./program.rb > output.txt redirects the output as well as the prompts for input into the text file, so you can't see what you're doing. You have several options:
Use STDERR.puts to prompt for input, so it doesn't get caught by the redirection. This is my preferred method.
Use ARGV to pass input to your program. This is a good option if you think the program isn't too hard to use without prompts.
Use File.open to create an output file and write to it directly. Sometimes this is the most sensible option, but usually you want to do one of the first two.
If the program is asking for input, maybe you can change your program to accept input from the command line (ARGV[0] etc), then redirect the output to a file :
ruby myprogram > out.txt
This worked for a simple puts output:
foo.rb:
foo = gets.chomp
puts "Input was: " + foo
Terminal:
ruby foo.rb > test.txt

Is there any way to execute .cmd file in Unix? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
How to create a .cmd file in .cmd file and pass variable in it to execute some command.
Is there any way to execute .cmd file in Unix ?
Kindly advice
Thanks,
No, not really
The .cmd files in windows are interpreted by the windows cmd.exe program. If you open one up, you'll find a .cmd file contains text commands to be executed.
In the Unix world the equivalent to command files are shell scripts. These have a .sh extension and are usually interpreted by the bash program.
Read more about shell scripts online
Well maybe...
you can run the cmd.exe program on Linux, Solaris Mac and BSD by using a compatibility layer called Wine However, because of differences between the platforms, you will have to revise you scripts and manually check that things like paths and executable names are still valid.

Building Program-Specific Shortcuts in UNIX [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a program, called carmel, which I can run from the command line via:
carmel -h
or whichever suffix I chose. When loading a file, I can say:
carmel fsa1.fst where fsa1.fst is located in my heme folder, /Users/adam/.
I would prefer to have the default file location be, e.g., /Users/adam/carmel/files, and would prefer to not type that in every time. Is there a way to let UNIX know, when I type carmel to then look in that location?
There is no standard Unix shortcut for this behaviour. Some applications will check an environment variable to see where their files are. but looking at carmel/src/carmel.cc on GitHub, I'd say you'd have to write a wrapper script. Like this:
#!/usr/bin/env bash
# Save as ${HOME}/bin/carmel and ensure ${HOME}/bin is before
# ${carmel_bin_dir} in your ${PATH}. Also ensure this script
# has the executable bit set.
carmel_bin_dir=/usr/local/bin # TODO change this?
working_directory=${CARMEL_HOME-${HOME}/carmel/files}
if [[ ! -d "${working_directory}" ]]; then
echo "${working_directory} does not exist. Creating."
mkdir -p "${working_directory}" || echo "Failed to create ${working_directory}"
fi
pushd "${working_directory}"
echo "Launching ${carmel_bin_dir}/carmel ${#} from $(pwd)..."
${carmel_bin_dir}/carmel ${#}
popd
Alternatively, since the source is freely available, you could add some code to read ${CARMEL_HOME} (or similar) and submit this as a pull request.
Good luck!

What is a shar file? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Reading the make's manual page:
`shar'
Create a shell archive (shar file) of the source files.
What is a shar?
It's a shell archive, a self extracting executable shell script which is meant to be a convenient way to ship archives of files and have them appear simply by running the script.
An example is shown in the transcript below which gives only one file from the archive, output.txt:
pax> cat shar.bash
#!/bin/bash
tr '[A-Za-z]' '[N-ZA-Mn-za-m]' >output.txt <<EOF
Uryyb sebz Cnk.
EOF
pax> ./shar.bash
pax> cat output.txt
Hello from Pax.
That's a fairly simplistic one since it only delivers one file, and it doesn't compress it at all, but it should give you the general idea.
A real one would probably give you something like a set of files combined with tar, gzip and uuencode, which would then be passed through uudecode, gunzip and tar to deliver the original content.
A self-extracting archive: a shell script that extracts some data contained in it.
Wikipedia has more: http://en.wikipedia.org/wiki/Shar
It's a kind of self-extracting archive.
It's a bit dangerous (like a self-extracting .exe on Windows), because it runs itself to extract itself, so it could potentially do all kinds of other things that you did not expect.
I think this is what Oracle uses to distribute the JVM on Linux (to make you click through a license agreement first).
Normally, people would just use tar archives (which cannot execute arbitrary code, but also not show any dialogs).

Resources