how do i open a file csv ? with the last command here vi
it open it the command prompt, but how do i open it on csv file normarlly
without open it on the command prompt?
[#dc1-ora rci]$ ls
backup diamond20130306.csv
diamond2012_04_30_dev.csv diamond_points_20120820.csv
diamond20120801.csv diamond_points_20120827.csv
diamond20120802.csv diamond_points_20120828.csv
diamond20120803.csv diamond_points_20121217.csv
diamond20120804.csv diamond_points_20130129.csv
diamond20120806.csv diamond_points_20130130.csv
diamond20120807.csv diamond_points_20130205.csv
diamond20120808.csv diamond_points_20130306.csv
diamond20120828.csv diamond_points_20130326.csv
diamond20120906.csv diamond_points_20130410.csv
diamond20121025.csv diamond_rental_20121219.csv
diamond20121029.csv diamond_rental_20121220.csv
diamond20121218.csv diamond_rental_20121221.csv
diamond20130128.csv ilx_final_lead_merge.csv
diamond20130129.csv test_diamond20120820.csv
diamond20130130.csv test_diamond20120827.csv
diamond20130131.csv test_diamond20120828.csv
diamond20130205.csv test.txt
diamond20130219.csv THH_RCT_RCI_EDM_FILE_01_28_13.csv
[#dc1-ora rci]$ vi test_diamond20120820.c
sv
( opens file here on the command prompt)
On windows/cmd you should do:
start notepad++ test_diamond20120820.csv
in your case:
start Excel.exe test_diamond20120820.csv
or for the default application associated with it use :
start test_diamond20120820.csv
(didn't test I am using linux maybe I will test it later if I reboot)
But I suspect you don't mean command prompt but a linux terminal (because of your tags):
you can use any of those:
gedit test_diamond20120820.csv &
nedit test_diamond20120820.csv &
etc depending on the programs you have installed
or for the default application associated with it use :
xdg-open test_diamond20120820.csv
if you are remotely logged in using ssh make sure you have X enabled
Related
I am using Execute process task in SSIS to execute below command line arguments to download the files to some local drive.
/log=G:\USER_DATA\IRM\IRM_SFTP_Logs\IRM_SFTP_Log_Details.txt /command "open sftp://bisftp:*UFVy2u6jnJ]#hU0Zer5AjvDU4#stransfer.xxx.com/ -hostkey=""ssh-rsa 2048 xxxxxxxxxxxxx""" "cd /DATA" "get GNRC_IRM_XXXX_EXTRACT*.zip GNRC_IRM_XXXX*.zip G:\USER_DATA\IRM\IRM_Download\" "exit"
This is running perfect and every time it appends logs to the existing file.
G:\USER_DATA\IRM\IRM_SFTP_Logs\IRM_SFTP_Log_Details.txt
Is there any way to overwrite the existing log file?
To disable session log file appending in WinSCP scripting, set Logging\LogFileAppend raw configuration option:
/log=... /rawconfig Logging\LogFileAppend=0 ...
I want to open a file from within R.
I can launch the software (graphpad prism) with the following:
system2("C:/Program Files (x86)/GraphPad/Prism 7/prism.exe")
I expected this to open my prism file as if I were double clicking on it or running it from cmd, but it didn't:
system2("H:/Graphs/Shell/Templates/NASH4_Standard.pzfx")
I am receiving the message:
Warning message: running command
'H:/Graphs/Shell/Templates/NASH4_Standard.pzfx' had status 127
I see that this is not an error but just a warning. Am I unintentionally "shelling" the document in the background? How would I make sure it pops up as a window?
Status 127 was addressed here, but for launching the software, not opening the document with it.
In Windows environments, you need to call a command line interpreter like CMD prompt or PowerShell. Also, any file path that has spaces needs to be enclosed in double quotes above the quotes needed in R for string literals (the case for your .exe not specific file).
With system() send entire command in one string:
system('cmd /c "H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"')
# POWER SHELL REQUIRES MORE QUOTE ESCAPING (ONLY ONE PAIR W/O SPACES)
system('powershell & """H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"""')
With system2() use the args parameter:
# FILES
system2('cmd', args=c('/c', '"H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"'))
system2('powershell', args=c(' & """H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"""'))
# EXECUTABLES
system2('cmd', args=c('/c', '"C:/Program Files (x86)/GraphPad/Prism 7/prism.exe"'))
system2('powershell', args=c(' & """C:/Program Files (x86)/GraphPad/Prism 7/prism.exe"""'))
shell.exec("C:/Program Files (x86)/GraphPad/Prism 7/prism.exe")
does it work for you ?
ps. and shell.exec("MyWorkbook.xls") open file with default program
I have written a QT GUI program where pressing a button will execute a .sh script. The contents of the script is-
echo -e 'attach database 'testdatabase.db' as 'aj';\n.separator ","\n.import ora_exported.csv qt_ora_exported' | sqlite3 testdatabase.db
basically the script will import a .csv to an sqlite database. And when the script file (script.sh) is run manually from linux terminal ($./script.sh) it successfully imports the .csv file into the database table.
But, when I call the script from my QT program
void MainWindow::on_importButton_clicked()
{
QProcess process;
process.startDetached("/bin/sh",QStringList()<<"/home/aj/script.sh");
}
it compiles successfully but gives an error message in console when the button is pressed at runtime.
Error: near line 1: near "-": syntax error
Error: cannot open "ora_exported.csv"
what could be causing this ???
EDITED
I have changed my .sh script now to--
echo -e 'attach database 'testdatabase.db' as 'aj';\n.separator ","\n.import /home/aj/ora_exported.csv qt_ora_exported' | sqlite3 testdatabase.db
Thus providing the path to my ora_exported.csv. As a result the runtime error [Error: cannot open "ora_exported.csv"] has gone but the other message [Error: near line 1: near "-": syntax error] is still coming.
Same as was observed in previous case, using ./script.sh is successfully importing data to sqlite3 db table file but QProcess is unable to.
echo is a built in command of a shell that may behave differently.
E.g. take this test script: echotest.sh
echo -e "123"
Now we can compare different results:
$ bash echotest.sh
123
$ zsh echotest.sh
123
$ dash echotest.sh
-e 123
You are probably on some Ubuntu-like OS, where /bin/sh redirects to dash. That would explain the error around "-". So if you are using echo, set you shell specificially or ensure that your script works on all common shells.
Additionally, you are messing up your quotations
echo -e 'attach database 'testdatabase.db' as 'aj';\n.separator ","\n.import /home/aj/ora_exported.csv qt_ora_exported'
results in (no quotations in the first line)
attach database testdatabase.db as aj;
.separator ","
.import /home/aj/ora_exported.csv qt_ora_exported
but you pobably want
echo -e "attach database 'testdatabase.db' as 'aj';\n.separator ','\n.import /home/aj/ora_exported.csv qt_ora_exported"
It looks strange that you are using external script to update database!
why you don't pass "ora_exported.csv" file name as a script argument? This would help solve the problem.
I was talking (typing) about this solution:
void MainWindow::on_importButton_clicked()
{
QProcess::startDetached("/bin/sh",
QStringList()<<"/home/aj/script.sh",
"<location of: 'ora_exported.csv' file>");
}
My requirement is used to create a ftp batch script to transfer files from Unix to Windows through the WinSCP command line. So, I pass file name to the script and file is transferred from Unix to Windows. However, when I want to transfer multiple files, the challenge here is to take all the file names from the user and run the WinSCP command to get all the files. How to loop the input for the different file names and construct the WinSCP command for the same?
Can someone help me with the approach as I am new to batch scripting?
Sample command to transfer a single file
call C:\Progra~2\WinSCP\WinSCP.exe /console /timeout="120" /command "option batch continue" "option confirm off" "open sftp://%userid%:%passw%#%host%" "get %/file/filename.txt%" "exit"
Sample command to transfer a multiple files
call C:\Progra~2\WinSCP\WinSCP.exe /console /timeout="120" /command "option batch continue" "option confirm off" "open sftp://%userid%:%passw%#%host%" "get %/file/filename.txt%" "get %/file/filename2.txt%" "get %/file/filename3.txt%" "exit"
In this case you do not have to take multiple inputs at all. The WinSCP command get can take multiple source files as arguments. You just have to use the target path as the last argument. Use the .\ to download to the current working directory (what is a default, when using a single argument only, just as in your example).
So you can prompt user only once to enter a space-separated list of files to download
set /p "list=Enter space separated list of files to download: "
winscp.com /command ^
"option batch continue" ^
"option confirm off" ^
"open sftp://%userid%:%passw%#%host%" ^
"get %list% .\" ^
"exit"
Side notes:
When running WinSCP from a batch file, use the winscp.com instead of the winscp.exe to avoid additional console window opening for WinSCP.
The command-line parameter /timeout=120 won't apply to sessions opened using the open command in the script. Use the -timeout=120 switch of the the open command:
open sftp://%userid%:%passw%#%host% -timeout=120
No point in using the call command to run WinSCP
I am assuming you are going to prompt the user input manually in the console. This will prompt for the user input repeatedly until it sees a dot .
#echo off
setlocal enabledelayedexpansion
:prompt
set /p "input=Enter the filename:"
if "!input!"=="." (
goto :begin ) else (
set input_all=!input_old! "!input!"
set input_old=!input_all!
goto :prompt
)
:begin
echo consolidated_input=!input_all!
Add your winscp command line after the label :begin
tested sample-
D:\Scripts>draft.bat
Enter the filename:c:\sample\test1.txt
Enter the filename:c:\sample\test2.log
Enter the filename:c:\sample\test3.ini
Enter the filename:.
consolidated_input= "c:\sample\test1.txt" "c:\sample\test2.log" "c:\sample\test3.ini"
Cheers, G
I cannot run a script in Eclipse that works perfectly in a terminal.
It seems that Eclipse console cannot support some functions. I am looking for a workaround to be able to debug the script using Pydev.
Is it possible to set PyDev to use for example /usr/bin/gnome-terminal instead of the Eclipse native console ?
Otherwise it there a way to define a wrapper as a python interpreter for PyDev that will launch an terminal external to Eclipse (I've tried but failed on that).
Thank you
Nga
Right now, curses-based apps really don't run well inside Eclipse/PyDev, so, you must really launch it externally. To debug you can use the remote debugger: http://pydev.org/manual_adv_remote_debugger.html
If you use Aptana Studio, there's a terminal view which should emulate a terminal better... try running python (i.e.: running your program) from inside that view. If it does work properly there, maybe I could check a way to better integrate there and launch directly in that view.
Thank you for your reply. I have finally defined kind of a wrapper as a bash script calling python in a xterm. Pydev is checking some configuration by calling eclipse/plugins/org.python.pydev_2.4.0.2012020116/PySrc/interpreterInfo.py so the script first echo the format expected by PyDev. here is the script "
#!/bin/bash
# dummy return for Eclipse Pydev - respect interpreter info format
echo "EXECUTABLE:/home/user/python_custom/python_xterm|
|/home/user/eclipse/plugins/org.python.pydev_2.4.0.2012020116/PySrc
|/usr/lib/python2.5
|/usr/lib/python2.5/plat-linux2
|/usr/lib/python2.5/lib-tk
|/usr/lib/python2.5/lib-dynload
|/usr/local/lib/python2.5/site-packages
|/usr/lib/python2.5/site-packages
|/usr/lib/python2.5/site-packages/Numeric
|/usr/lib/python2.5/site-packages/PIL
|/usr/lib/python2.5/site-packages/gst-0.10
|/var/lib/python-support/python2.5
|/usr/lib/python2.5/site-packages/gtk-2.0
|/var/lib/python-support/python2.5/gtk-2.0
|/var/lib/python-support/python2.5/HTMLgen
|/var/lib/python-support/python2.5/pyinotify
|/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode
|/usr/lib/site-python
#
$
|__builtin__
|__main__
|_ast
|_codecs
|_sre
|_symtable
|_types
|errno
|exceptions
|gc
|imp
|marshal
|posix
|pwd
|signal
|sys
|thread
|xxsubtype
|zipimport
"
# activate scrollbar -sb with 6000 lines
# allow logging -l with filename log_$NOW
xterm -g 150x100+0+0 -sb -sl 6000 -si -hold -e "python $*"
that does the job, and I can use Pydev and its debugger